Skip to content

Commit

Permalink
e2e: print skipped tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillzyusko committed Oct 23, 2024
1 parent d2c4a0d commit b8a0935
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions tests/e2e/compare/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,19 @@ type Options = {
outputFile: string;
outputFormat: 'console' | 'markdown' | 'all';
metricForTest: Record<string, Unit>;
hasMissingData: boolean;
skippedTests: string[];
};

export default (main: Metric | string, delta: Metric | string, {outputFile, outputFormat = 'all', metricForTest = {}, hasMissingData}: Options) => {
export default (main: Metric | string, delta: Metric | string, {outputFile, outputFormat = 'all', metricForTest = {}, skippedTests}: Options) => {
// IMPORTANT NOTE: make sure you are passing the main/baseline results first, then the delta/compare results:
const outputData = compareResults(main, delta, metricForTest);

if (outputFormat === 'console' || outputFormat === 'all') {
printToConsole(outputData, hasMissingData);
printToConsole(outputData, skippedTests);
}

if (outputFormat === 'markdown' || outputFormat === 'all') {
return writeToMarkdown(outputFile, outputData, hasMissingData);
return writeToMarkdown(outputFile, outputData, skippedTests);
}
};
export {compareResults};
6 changes: 3 additions & 3 deletions tests/e2e/compare/output/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const printRegularLine = (entry: Entry) => {
/**
* Prints the result simply to console.
*/
export default (data: Data, hasMissingData: boolean) => {
export default (data: Data, skippedTests: string[]) => {
// No need to log errors or warnings as these were be logged on the fly
console.debug('');
console.debug('❇️ Performance comparison results:');
Expand All @@ -39,8 +39,8 @@ export default (data: Data, hasMissingData: boolean) => {

console.debug('');

if (hasMissingData) {
console.debug('⚠️ Some tests did not pass successfully, so some results are omitted from final report');
if (skippedTests.length > 0) {
console.debug(`⚠️ Some tests did not pass successfully, so some results are omitted from final report: ${skippedTests.join(', ')}`);
}
};

Expand Down
10 changes: 5 additions & 5 deletions tests/e2e/compare/output/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const buildSummaryTable = (entries: Entry[], collapse = false) => {
return collapse ? collapsibleSection('Show entries', content) : content;
};

const buildMarkdown = (data: Data, hasMissingData: boolean) => {
const buildMarkdown = (data: Data, skippedTests: string[]) => {
let result = '## Performance Comparison Report 📊';

if (data.errors?.length) {
Expand All @@ -92,8 +92,8 @@ const buildMarkdown = (data: Data, hasMissingData: boolean) => {
result += `\n${buildDetailsTable(data.meaningless)}`;
result += '\n';

if (hasMissingData) {
result += '⚠️ Some tests did not pass successfully, so some results are omitted from final report';
if (skippedTests.length > 0) {
result += `⚠️ Some tests did not pass successfully, so some results are omitted from final report: ${skippedTests.join(', ')}`;
}

return result;
Expand All @@ -113,8 +113,8 @@ const writeToFile = (filePath: string, content: string) =>
throw error;
});

const writeToMarkdown = (filePath: string, data: Data, hasMissingData: boolean) => {
const markdown = buildMarkdown(data, hasMissingData);
const writeToMarkdown = (filePath: string, data: Data, skippedTests: string[]) => {
const markdown = buildMarkdown(data, skippedTests);
return writeToFile(filePath, markdown).catch((error) => {
console.error(error);
throw error;
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ const runTests = async (): Promise<void> => {
}
};

let hasSkippedTests = false;
let skippedTests: string[] = [];

Check failure on line 126 in tests/e2e/testRunner.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'skippedTests' is never reassigned. Use 'const' instead
const clearTestResults = (test: TestConfig) => {
hasSkippedTests = true;
skippedTests.push(test.name);

Object.keys(results).forEach((branch: string) => {
Object.keys(results[branch]).forEach((metric: string) => {
Expand Down Expand Up @@ -352,7 +352,7 @@ const runTests = async (): Promise<void> => {
outputFile: `${config.OUTPUT_DIR}/output.md`,
outputFormat: 'all',
metricForTest,
hasMissingData: hasSkippedTests,
skippedTests,
});

await server.stop();
Expand Down

0 comments on commit b8a0935

Please sign in to comment.