Skip to content

Commit

Permalink
fix: e2e results not being posted
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillzyusko committed Jul 8, 2024
1 parent 51dd814 commit ed3348b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
`<rootDir>/tests/ui/**/*.${testFileExtension}`,
`<rootDir>/tests/unit/**/*.${testFileExtension}`,
`<rootDir>/tests/actions/**/*.${testFileExtension}`,
`<rootDir>/tests/e2e/**/*.${testFileExtension}`,
`<rootDir>/?(*.)+(spec|test).${testFileExtension}`,
],
transform: {
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/compare/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@ export default (main: Metric | string, delta: Metric | string, outputFile: strin
return writeToMarkdown(outputFile, outputData);
}
};
export {compareResults};
11 changes: 5 additions & 6 deletions tests/e2e/compare/output/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,19 @@ const buildDurationDetailsEntry = (entry: Entry) =>
.join('<br/><br/>');

const formatEntryDuration = (entry: Entry): string => {
let formattedDuration = '';

if ('baseline' in entry && 'current' in entry) {
formattedDuration = format.formatMetricDiffChange(entry);
return format.formatMetricDiffChange(entry);
}

if ('baseline' in entry) {
formattedDuration = format.formatMetric(entry.baseline.mean, entry.unit);
return format.formatMetric((entry as Entry).baseline.mean, (entry as Entry).unit);
}

if ('current' in entry) {
formattedDuration = format.formatMetric(entry.current.mean, entry.unit);
return format.formatMetric((entry as Entry).current.mean, (entry as Entry).unit);
}

return formattedDuration;
return '';
};

const buildDetailsTable = (entries: Entry[]) => {
Expand Down Expand Up @@ -120,3 +118,4 @@ const writeToMarkdown = (filePath: string, data: Data) => {
};

export default writeToMarkdown;
export {buildMarkdown};
24 changes: 24 additions & 0 deletions tests/e2e/compare/output/spec/__snapshots__/markdown.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`markdown formatter should format significant changes properly 1`] = `
"## Performance Comparison Report 📊
### Significant Changes To Duration
| Name | Duration |
| -------------- | --------------------------------------------------- |
| commentLinking | 131.681 ms → 421.806 ms (+290.125 ms, +220.3%) 🔴🔴 |
<details>
<summary>Show details</summary>
| Name | Duration |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| commentLinking | **Baseline**<br/>Mean: 131.681 ms<br/>Stdev: 19.883 ms (15.1%)<br/>Runs: 100.5145680010319 112.0048420019448 121.8861090019345 124.26110899820924 135.1571460030973 140.33837900310755 158.5825610011816 160.7034499980509<br/><br/>**Current**<br/>Mean: 421.806 ms<br/>Stdev: 30.185 ms (7.2%)<br/>Runs: 361.5145680010319 402.8861090019345 412.0048420019448 414.26110899820924 425.1571460030973 440.33837900310755 458.7034499980509 459.5825610011816 |
</details>
### Meaningless Changes To Duration
_There are no entries_
"
`;
18 changes: 18 additions & 0 deletions tests/e2e/compare/output/spec/markdown.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {compareResults} from '../../compare';
import {buildMarkdown} from '../markdown';

const results = {
main: {
commentLinking: [100.5145680010319, 121.8861090019345, 112.0048420019448, 124.26110899820924, 135.1571460030973, 140.33837900310755, 160.7034499980509, 158.5825610011816],
},
delta: {
commentLinking: [361.5145680010319, 402.8861090019345, 412.0048420019448, 414.26110899820924, 425.1571460030973, 440.33837900310755, 458.7034499980509, 459.5825610011816],
},
};

describe('markdown formatter', () => {
it('should format significant changes properly', () => {
const data = compareResults(results.main, results.delta, {commentLinking: 'ms'});
expect(buildMarkdown(data)).toMatchSnapshot();
});
});

0 comments on commit ed3348b

Please sign in to comment.