Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report design tweaks #245

Merged
merged 3 commits into from Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 34 additions & 33 deletions dist/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/format/formatRunReport.ts
Expand Up @@ -2,7 +2,7 @@ import { TestRunReport } from '../typings/Report';
import { createMarkdownSpoiler } from '../utils/createMarkdownSpoiler';

export const formatRunReport = (report: TestRunReport): string => {
const parts = [`# ${report.title}`];
const parts = [`## ${report.title}`];
if (report.failures) {
parts.push(
createMarkdownSpoiler({
Expand All @@ -11,7 +11,7 @@ export const formatRunReport = (report: TestRunReport): string => {
})
);
} else {
parts.push(`## ${report.summary}`);
parts.push(report.summary);
}
return parts.join('\n');
};
2 changes: 1 addition & 1 deletion src/format/strings.json
Expand Up @@ -67,7 +67,7 @@
},
"failed": "Jest coverage report action failed",
"status": "St.",
"statusExplanation": "Status of coverage: :green_circle: - ok, :yellow_circle: - slightly more than threshold, :red_circle: - under the threshold",
"statusExplanation": "Status of coverage:
 :green_circle: - ok
 :yellow_circle: - slightly more than threshold
 :red_circle: - under the threshold",
"category": "Category",
"percentage": "Percentage",
"ratio": "Covered / Total",
Expand Down
1 change: 1 addition & 0 deletions src/utils/createMarkdownSpoiler.ts
Expand Up @@ -8,6 +8,7 @@ export const createMarkdownSpoiler = ({
summary,
}: SpoilerConfig): string => `
<details><summary>${summary}</summary>
<br/>

${body}

Expand Down
36 changes: 18 additions & 18 deletions tests/format/__snapshots__/formatCoverage.test.ts.snap
@@ -1,34 +1,34 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`formatCoverage should format standard coverage 1`] = `
"| <div title=\\"Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold\\">St.<sup>:grey_question:</sup></div> | Category | Percentage | Covered / Total |
| :---------------------------------------------------------------------------------------------------------------------------------------: | :--------- | :--------- | :-------------: |
| 🟢 | Statements | 81.82% | 27/33 |
| 🟢 | Branches | 100% | 8/8 |
| 🟢 | Functions | 63.64% | 7/11 |
| 🟢 | Lines | 80.65% | 25/31 |
"| <div title=\\"Status of coverage:&#10; 🟢 - ok&#10; 🟡 - slightly more than threshold&#10; 🔴 - under the threshold\\">St.<sup>:grey_question:</sup></div> | Category | Percentage | Covered / Total |
| :----------------------------------------------------------------------------------------------------------------------------------------------------: | :--------- | :--------- | :-------------: |
| 🟢 | Statements | 81.82% | 27/33 |
| 🟢 | Branches | 100% | 8/8 |
| 🟢 | Functions | 63.64% | 7/11 |
| 🟢 | Lines | 80.65% | 25/31 |

"
`;

exports[`formatCoverage should format standard coverage 2`] = `
"| <div title=\\"Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold\\">St.<sup>:grey_question:</sup></div> | Category | Percentage | Covered / Total |
| :---------------------------------------------------------------------------------------------------------------------------------------: | :--------- | :--------- | :-------------: |
| 🟢 | Statements | 81.82% | 27/33 |
| 🟢 | Branches | 100% | 8/8 |
| 🟢 | Functions | 63.64% | 7/11 |
| 🟢 | Lines | 80.65% | 25/31 |
"| <div title=\\"Status of coverage:&#10; 🟢 - ok&#10; 🟡 - slightly more than threshold&#10; 🔴 - under the threshold\\">St.<sup>:grey_question:</sup></div> | Category | Percentage | Covered / Total |
| :----------------------------------------------------------------------------------------------------------------------------------------------------: | :--------- | :--------- | :-------------: |
| 🟢 | Statements | 81.82% | 27/33 |
| 🟢 | Branches | 100% | 8/8 |
| 🟢 | Functions | 63.64% | 7/11 |
| 🟢 | Lines | 80.65% | 25/31 |

"
`;

exports[`formatCoverage should format standard coverage 3`] = `
"| <div title=\\"Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold\\">St.<sup>:grey_question:</sup></div> | Category | Percentage | Covered / Total |
| :---------------------------------------------------------------------------------------------------------------------------------------: | :--------- | :--------- | :-------------: |
| 🟢 | Statements | 81.82% | 27/33 |
| 🟢 | Branches | 100% | 8/8 |
| 🟡 | Functions | 63.64% | 7/11 |
| 🟢 | Lines | 80.65% | 25/31 |
"| <div title=\\"Status of coverage:&#10; 🟢 - ok&#10; 🟡 - slightly more than threshold&#10; 🔴 - under the threshold\\">St.<sup>:grey_question:</sup></div> | Category | Percentage | Covered / Total |
| :----------------------------------------------------------------------------------------------------------------------------------------------------: | :--------- | :--------- | :-------------: |
| 🟢 | Statements | 81.82% | 27/33 |
| 🟢 | Branches | 100% | 8/8 |
| 🟡 | Functions | 63.64% | 7/11 |
| 🟢 | Lines | 80.65% | 25/31 |

"
`;
7 changes: 4 additions & 3 deletions tests/format/__snapshots__/formatRunReport.test.ts.snap
@@ -1,9 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`formatRunReport should generate summary as markdown (failure tests) 1`] = `
"# Tests Failed
"## Tests Failed

<details><summary>2 Tests Passed, 1 Test Failed</summary>
<br/>

\`\`\`
fail 1
Expand All @@ -18,6 +19,6 @@ fail 2
`;

exports[`formatRunReport should generate summary as markdown (successful tests) 1`] = `
"# Tests Passed
## 2 Tests Passed"
"## Tests Passed
2 Tests Passed"
`;
12 changes: 6 additions & 6 deletions tests/format/__snapshots__/getFormattedCoverage.test.ts.snap
@@ -1,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`getFormattedCoverage should match snapshots 1`] = `
"| <div title=\\"Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold\\">St.<sup>:grey_question:</sup></div> | Category | Percentage | Covered / Total |
| :---------------------------------------------------------------------------------------------------------------------------------------: | :--------- | :--------- | :-------------: |
| 🟢 | Statements | 81.82% | 27/33 |
| 🟢 | Branches | 100% | 8/8 |
| 🟡 | Functions | 63.64% | 7/11 |
| 🟢 | Lines | 80.65% | 25/31 |
"| <div title=\\"Status of coverage:&#10; 🟢 - ok&#10; 🟡 - slightly more than threshold&#10; 🔴 - under the threshold\\">St.<sup>:grey_question:</sup></div> | Category | Percentage | Covered / Total |
| :----------------------------------------------------------------------------------------------------------------------------------------------------: | :--------- | :--------- | :-------------: |
| 🟢 | Statements | 81.82% | 27/33 |
| 🟢 | Branches | 100% | 8/8 |
| 🟡 | Functions | 63.64% | 7/11 |
| 🟢 | Lines | 80.65% | 25/31 |

"
`;
Expand Up @@ -3,19 +3,21 @@
exports[`formatCoverageDetails should match snapshots 1`] = `
"
<details><summary>Show new covered files 🐣</summary>
<br/>

| <div title=\\"Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold\\">St.<sup>:grey_question:</sup></div> | File | Statements | Branches | Functions | Lines |
| :---------------------------------------------------------------------------------------------------------------------------------------: | :--------- | :--------- | :------- | :-------- | :---- |
| 🔴 | newFile.ts | 50% | 50% | 50% | 50% |
| <div title=\\"Status of coverage:&#10; 🟢 - ok&#10; 🟡 - slightly more than threshold&#10; 🔴 - under the threshold\\">St.<sup>:grey_question:</sup></div> | File | Statements | Branches | Functions | Lines |
| :----------------------------------------------------------------------------------------------------------------------------------------------------: | :--------- | :--------- | :------- | :-------- | :---- |
| 🔴 | newFile.ts | 50% | 50% | 50% | 50% |

</details>


<details><summary>Show files with reduced coverage 🔻</summary>
<br/>

| <div title=\\"Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold\\">St.<sup>:grey_question:</sup></div> | File | Statements | Branches | Functions | Lines |
| :---------------------------------------------------------------------------------------------------------------------------------------: | :----------- | :----------------------------------------------------- | :----------------------------------------------------- | :----------------------------------------------------- | :----------------------------------------------------- |
| 🟡 | decreased.ts | <div title=\\"Base coverage is: 80%\\">70% (-10% 🔻)</div> | <div title=\\"Base coverage is: 60%\\">50% (-10% 🔻)</div> | <div title=\\"Base coverage is: 60%\\">50% (-10% 🔻)</div> | <div title=\\"Base coverage is: 90%\\">80% (-10% 🔻)</div> |
| <div title=\\"Status of coverage:&#10; 🟢 - ok&#10; 🟡 - slightly more than threshold&#10; 🔴 - under the threshold\\">St.<sup>:grey_question:</sup></div> | File | Statements | Branches | Functions | Lines |
| :----------------------------------------------------------------------------------------------------------------------------------------------------: | :----------- | :----------------------------------------------------- | :----------------------------------------------------- | :----------------------------------------------------- | :----------------------------------------------------- |
| 🟡 | decreased.ts | <div title=\\"Base coverage is: 80%\\">70% (-10% 🔻)</div> | <div title=\\"Base coverage is: 60%\\">50% (-10% 🔻)</div> | <div title=\\"Base coverage is: 60%\\">50% (-10% 🔻)</div> | <div title=\\"Base coverage is: 90%\\">80% (-10% 🔻)</div> |

</details>
"
Expand Down