mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-17 06:47:09 +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:
parent
0d00bb14cb
commit
fe8fe90f0e
9 changed files with 286 additions and 105 deletions
|
|
@ -66,4 +66,27 @@ describe('jest-junit tests', () => {
|
|||
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
|
||||
fs.writeFileSync(outputPath, report)
|
||||
})
|
||||
|
||||
it('jest testsuite errors example test results matches snapshot', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'test-errors', 'jest', 'jest-test-results.xml')
|
||||
const trackedFilesPath = path.join(__dirname, 'fixtures', 'test-errors', 'jest', 'files.txt')
|
||||
const outputPath = path.join(__dirname, '__outputs__', 'jest-test-errors-results.md')
|
||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
|
||||
const trackedFiles = fs.readFileSync(trackedFilesPath, {encoding: 'utf8'}).split(/\n\r?/g)
|
||||
const opts: ParseOptions = {
|
||||
parseErrors: true,
|
||||
trackedFiles
|
||||
//workDir: '/home/dorny/dorny/jest/'
|
||||
}
|
||||
|
||||
const parser = new JestJunitParser(opts)
|
||||
const result = await parser.parse(filePath, fileContent)
|
||||
expect(result).toMatchSnapshot()
|
||||
|
||||
const report = getReport([result])
|
||||
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
|
||||
fs.writeFileSync(outputPath, report)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue