Skip to content

Commit f94ae50

Browse files
authored
Merge pull request #52 from crammond/identify-empty-junit-testsuites
Check for key existence to identify junit file
2 parents c250037 + e4f3394 commit f94ae50

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/test_parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export async function parseFile(filename: string): Promise<TestResult> {
316316

317317
const xml: any = await parser(data)
318318

319-
if (xml.testsuites || xml.testsuite) {
319+
if ('testsuites' in xml || 'testsuite' in xml) {
320320
return await parseJunitXml(xml)
321321
}
322322

test/file.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,11 @@ describe("file", async () => {
5555
expect(result.counts.failed).to.eql(4)
5656
expect(result.counts.skipped).to.eql(2)
5757
})
58+
59+
it("identifies empty junit", async () => {
60+
const result = await parseFile(`${junitResourcePath}/05-empty.xml`)
61+
expect(result.counts.passed).to.eql(0)
62+
expect(result.counts.failed).to.eql(0)
63+
expect(result.counts.skipped).to.eql(0)
64+
})
5865
})

0 commit comments

Comments
 (0)