1
0
Fork 0
mirror of https://github.com/dorny/test-reporter.git synced 2026-03-21 23:52:12 +01:00

Report jest-junit testsuite errors as failures

Test errors are different (represented differently in the JUnit XML
output from jest-junit) to test _failures_. Failures are tests
which ran and failed, errors are for tests/test suites which
did not even run because the test code itself didn't build
or didn't execute correctly.

jest-junit has an option to enable reporting of test suite errors,
but test-reporter then interprets these as successful tests.
This commit is contained in:
Jozef Izso 2026-03-15 13:07:22 +01:00
parent 540c28072b
commit f8ae4deee6
Failed to extract signature
7 changed files with 141 additions and 3 deletions

View file

@ -75,17 +75,18 @@ export class JestJunitParser implements TestParser {
}
private getTestCaseResult(test: TestCase): TestExecutionResult {
if (test.failure) return 'failed'
if (test.failure || test.error) return 'failed'
if (test.skipped) return 'skipped'
return 'success'
}
private getTestCaseError(tc: TestCase): TestCaseError | undefined {
if (!this.options.parseErrors || !tc.failure) {
if (!this.options.parseErrors || !(tc.failure || tc.error)) {
return undefined
}
const details = typeof tc.failure[0] === 'string' ? tc.failure[0] : tc.failure[0]['_']
const message = tc.failure ? tc.failure[0] : tc.error ? tc.error[0] : 'unknown failure'
const details = typeof message === 'string' ? message : message['_']
let path
let line

View file

@ -31,4 +31,5 @@ export interface TestCase {
}
failure?: string[]
skipped?: string[]
error?: string[]
}