Skip to content

Commit

Permalink
Fix errors for old junit format (#34)
Browse files Browse the repository at this point in the history
* fix errors for old junit format

* 1.0.17
  • Loading branch information
MishaKav authored Oct 15, 2022
1 parent 3c924f4 commit ebc4ddf
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
5 changes: 4 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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-comment",
"version": "1.0.16",
"version": "1.0.17",
"description": "Comments a pull request or commit with the jest code coverage badge, full report and tests summary",
"author": "Misha Kav <[email protected]>",
"license": "MIT",
Expand Down
7 changes: 6 additions & 1 deletion src/junit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@ async function parseJunit(xmlContent: string): Promise<Junit | null> {

const main = parsedJunit.testsuites['$']
const testsuites = parsedJunit.testsuites.testsuite
const errors =
testsuites
?.map((t: any) => Number(t['$'].errors))
.reduce((sum: number, a: number) => sum + a, 0) || 0

const skipped =
testsuites
?.map((t: any) => Number(t['$'].skipped))
.reduce((sum: number, a: number) => sum + a, 0) || 0

return {
skipped,
errors: Number(main.errors),
errors: Number(main.errors || errors),
failures: Number(main.failures),
tests: Number(main.tests),
time: Number(main.time),
Expand Down

0 comments on commit ebc4ddf

Please sign in to comment.