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:
John Bartholomew 2021-12-22 19:10:19 +00:00
parent 0d00bb14cb
commit fe8fe90f0e
9 changed files with 286 additions and 105 deletions

View file

@ -1,5 +1,68 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`jest-junit tests jest testsuite errors example test results matches snapshot 1`] = `
TestRunResult {
"path": "fixtures/test-errors/jest/jest-test-results.xml",
"suites": Array [
TestSuiteResult {
"groups": Array [
TestGroupResult {
"name": "Test suite failed to run",
"tests": Array [
TestCaseResult {
"error": Object {
"details": " ● Test suite failed to run
tsconfig.json:13:3 - error TS6258: 'typeRoots' should be set inside the 'compilerOptions' object of the config json file
13 \\"typeRoots\\": [\\"./src/lib/types\\", \\"./node_modules/@types\\"],
~~~~~~~~~~~
",
"line": undefined,
"path": undefined,
},
"name": "libs/foo.spec.ts",
"result": "failed",
"time": 0,
},
],
},
],
"name": "libs/foo.spec.ts",
"totalTime": 0,
},
TestSuiteResult {
"groups": Array [
TestGroupResult {
"name": "Test suite failed to run",
"tests": Array [
TestCaseResult {
"error": Object {
"details": " ● Test suite failed to run
tsconfig.json:13:3 - error TS6258: 'typeRoots' should be set inside the 'compilerOptions' object of the config json file
13 \\"typeRoots\\": [\\"./src/lib/types\\", \\"./node_modules/@types\\"],
~~~~~~~~~~~
",
"line": undefined,
"path": undefined,
},
"name": "libs/bar.spec.ts",
"result": "failed",
"time": 0,
},
],
},
],
"name": "libs/bar.spec.ts",
"totalTime": 0,
},
],
"totalTime": 646,
}
`;
exports[`jest-junit tests report from ./reports/jest test results matches snapshot 1`] = `
TestRunResult {
"path": "fixtures/jest-junit.xml",