diff --git a/src/test_parser.ts b/src/test_parser.ts index d94e21b..9798822 100644 --- a/src/test_parser.ts +++ b/src/test_parser.ts @@ -250,7 +250,11 @@ async function parseJunitXml(xml: any): Promise { const element = failure_or_error[0] message = element.$ ? element.$.message : undefined - details = element._ + if (typeof element === "string") { + details = element + } else { + details = element._ + } counts.failed++ } else { diff --git a/test/junit.ts b/test/junit.ts index 204d8b1..df1e5aa 100644 --- a/test/junit.ts +++ b/test/junit.ts @@ -150,4 +150,12 @@ describe("junit", async () => { it("parses testsuite with no failure message", async () => { const result = await parseJunitFile(`${resourcePath}/07-no-failure-message.xml`) }) + + it("parses attributeless failure tags", async () => { + // https://github.com/jest-community/jest-junit generates failure tags + // that have no attributes, only inner text. + // Example: Failed! + const result = await parseJunitFile(`${resourcePath}/08-failure-noattr-only-innertext.xml`) + expect(result.suites[0].cases[0].details).to.eql("Failed!") + }) }) diff --git a/test/resources/junit/08-failure-noattr-only-innertext.xml b/test/resources/junit/08-failure-noattr-only-innertext.xml new file mode 100644 index 0000000..3835ca1 --- /dev/null +++ b/test/resources/junit/08-failure-noattr-only-innertext.xml @@ -0,0 +1,8 @@ + + + + + Failed! + + +