Skip to content

Commit

Permalink
When summary has non numeric "pct", the output is "Unknown% (pamepeix…
Browse files Browse the repository at this point in the history
…inho#12)

- fixed not numeric pct (percentage) to be 0
  • Loading branch information
michaelrodov authored and pamepeixinho committed Jan 29, 2019
1 parent 00970b6 commit 11a207c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const findArgument = (argName, defaultOutput) => {
}
}


const outputPath = findArgument('output', './coverage');
const inputPath = findArgument('input', './coverage/coverage-summary.json');

Expand All @@ -53,7 +52,7 @@ const getBadge = (report, key) => {
throw new Error('malformed coverage report');
}

const coverage = report.total[key].pct;
const coverage = (!report.total[key] || typeof report.total[key].pct !== 'number') ? 0 : report.total[key].pct;
const colour = getColour(coverage);

return `https://img.shields.io/badge/Coverage${encodeURI(':')}${key}-${coverage}${encodeURI('%')}-${colour}.svg`;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jest-coverage-badges",
"version": "1.1.2",
"version": "1.1.3",
"description": "Create a group of coverage badges from jest",
"main": "cli.js",
"bin": "cli.js",
Expand Down

0 comments on commit 11a207c

Please sign in to comment.