Skip to content

Commit

Permalink
Fix root element at junit (#86)
Browse files Browse the repository at this point in the history
* Handle case when testsuites is not the root element of the JUnit xml file (#85)

* Update junit.ts

* Update junit.test.ts

* build

* 1.0.26

* bump prod packages

* changelog

---------

Co-authored-by: Jacob Fulton <[email protected]>
  • Loading branch information
MishaKav and JakeFDev authored Apr 30, 2024
1 parent c2d5cfd commit 434e6d2
Show file tree
Hide file tree
Showing 7 changed files with 308 additions and 247 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog of the Jest Coverage Comment

## [Jest Coverage Comment 1.0.26](https://github.com/MishaKav/jest-coverage-comment/tree/v1.0.26)

**Release Date:** 2024-04-30

#### Changes

- Handle case when testsuites is not the root element of the JUnit xml file, thanks to [@JakeFDev](https://github.com/JakeFDev) for contribution

## [Jest Coverage Comment 1.0.25](https://github.com/MishaKav/jest-coverage-comment/tree/v1.0.25)

**Release Date:** 2024-01-30
Expand Down
12 changes: 12 additions & 0 deletions __tests__/junit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ describe('parsing junit', () => {
'Parse JUnit report. Non-whitespace before first tag.\nLine: 0\nColumn: 1\nChar: b'
)
})

test('should work with omitted parent testsuites element', async () => {
const xml =
'<?xml version="1.0" encoding="UTF-8"?><testsuite name="should test controller" errors="0" failures="0" skipped="0" timestamp="2022-03-21T21:15:26" time="0.981" tests="2"><testcase classname="should test controller when #getPost method method succeeds" name="should test controller when #getPost method method succeeds" time="0.004"></testcase><testcase classname="should test controller when #getPost method method fails" name="should test controller when #getPost method method fails" time="0.001"></testcase></testsuite>'
const junit = await parseJunit(xml)

expect(junit?.skipped).toBe(0)
expect(junit?.errors).toBe(0)
expect(junit?.failures).toBe(0)
expect(junit?.tests).toBe(2)
expect(junit?.time).toBe(0.981)
})
})

describe('parse junit and check report output', () => {
Expand Down
13 changes: 11 additions & 2 deletions 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.

Loading

0 comments on commit 434e6d2

Please sign in to comment.