Skip to content

Commit 7e4e69c

Browse files
authored
fix(ts): coverage only if it passed (#30)
## Describe your changes * It was giving coverage results even when there are no tests related to it * ![image](https://github.com/user-attachments/assets/7341da90-f3c8-4aa9-bc3c-f878833240e8) ## Reminder: - When the PR is ready, be sure to run `npm run build` to compile into the distribution `/dist` folder, which is the source code that the Action uses.
1 parent 8162f5a commit 7e4e69c

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

dist/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26208,7 +26208,7 @@ function formatResults(results, coverageResults, showCoverage) {
2620826208
});
2620926209
let coverageText = "N/A";
2621026210
let uncoveredLinesDetails = "";
26211-
if (coverageInfo) {
26211+
if (coverageInfo && result.status === "PASS") {
2621226212
try {
2621326213
coverageText = `${coverageInfo.coverage.toFixed(2)}%`;
2621426214
if (coverageInfo.notCoveredLines &&
@@ -26220,7 +26220,6 @@ function formatResults(results, coverageResults, showCoverage) {
2622026220
catch (error) {
2622126221
console.error("Error processing coverage information:", error);
2622226222
console.log("Coverage Info:", coverageInfo);
26223-
// Keep coverageText as "N/A" or set to an error message if preferred
2622426223
}
2622526224
}
2622626225
row += ` ${coverageText} |`;

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/formatResults.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export function formatResults(
7272

7373
let coverageText = "N/A";
7474
let uncoveredLinesDetails = "";
75-
if (coverageInfo) {
75+
if (coverageInfo && result.status === "PASS") {
7676
try {
7777
coverageText = `${coverageInfo.coverage.toFixed(2)}%`;
7878
if (
@@ -85,7 +85,6 @@ export function formatResults(
8585
} catch (error) {
8686
console.error("Error processing coverage information:", error);
8787
console.log("Coverage Info:", coverageInfo);
88-
// Keep coverageText as "N/A" or set to an error message if preferred
8988
}
9089
}
9190
row += ` ${coverageText} |`;

0 commit comments

Comments
 (0)