Skip to content

Commit

Permalink
feat(plugin-coverage): include decimals in coverage percentage used a…
Browse files Browse the repository at this point in the history
…s audit value
  • Loading branch information
matejchalk committed Jun 27, 2024
1 parent 2627a87 commit afeeb8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions e2e/cli-e2e/tests/__snapshots__/collect.e2e.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ exports[`CLI collect > should run Code coverage plugin that runs coverage tool a
},
],
},
"displayValue": "56 %",
"displayValue": "55.6 %",
"score": 0.5556,
"slug": "function-coverage",
"title": "Function coverage",
"value": 56,
"value": 55.55555555555556,
},
{
"description": "Measures how many branches were executed after conditional statements in at least one test.",
Expand All @@ -88,11 +88,11 @@ exports[`CLI collect > should run Code coverage plugin that runs coverage tool a
},
],
},
"displayValue": "88 %",
"displayValue": "87.5 %",
"score": 0.875,
"slug": "branch-coverage",
"title": "Branch coverage",
"value": 88,
"value": 87.5,
},
{
"description": "Measures how many lines of code were executed in at least one test.",
Expand Down Expand Up @@ -210,11 +210,11 @@ exports[`CLI collect > should run Code coverage plugin that runs coverage tool a
},
],
},
"displayValue": "62 %",
"displayValue": "62.1 %",
"score": 0.6211,
"slug": "line-coverage",
"title": "Line coverage",
"value": 62,
"value": 62.10526315789474,
},
],
"description": "Official Code PushUp code coverage plugin.",
Expand Down Expand Up @@ -347,11 +347,11 @@ exports[`CLI collect > should run Code coverage plugin which collects passed res
},
],
},
"displayValue": "76 %",
"displayValue": "76.5 %",
"score": 0.7647,
"slug": "branch-coverage",
"title": "Branch coverage",
"value": 76,
"value": 76.47058823529412,
},
{
"description": "Measures how many lines of code were executed in at least one test.",
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-coverage/src/lib/runner/lcov/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ export function lcovCoverageToAuditOutput(
): AuditOutput {
const coverage = calculateCoverage(stat.totalHit, stat.totalFound);
const MAX_DECIMAL_PLACES = 4;
const roundedIntValue = toNumberPrecision(coverage * 100, 0);
const coveragePercentage = coverage * 100;

return {
slug: `${coverageType}-coverage`,
score: toNumberPrecision(coverage, MAX_DECIMAL_PLACES),
value: roundedIntValue,
displayValue: `${roundedIntValue} %`,
value: coveragePercentage,
displayValue: `${toNumberPrecision(coveragePercentage, 1)} %`,
details: {
issues: stat.issues,
},
Expand Down

0 comments on commit afeeb8e

Please sign in to comment.