mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-16 06:17:10 +01:00
Gracefully handle empty nested testsuite elements for JUnit.
This fixes an issue with mocha-junit-reporter returning empty root-level testsuite elements.
This commit is contained in:
parent
0d9714ddc7
commit
a3356fa639
4 changed files with 27 additions and 2 deletions
|
|
@ -7,7 +7,7 @@ import {getReport} from '../src/report/get-report'
|
|||
import {normalizeFilePath} from '../src/utils/path-utils'
|
||||
|
||||
describe('jest-junit tests', () => {
|
||||
it('produces empty test run result when there are no test cases', async () => {
|
||||
it('produces empty test run result when there are no test cases in the testsuites element', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'empty', 'jest-junit.xml')
|
||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
|
|
@ -23,6 +23,22 @@ describe('jest-junit tests', () => {
|
|||
expect(result.result).toBe('success')
|
||||
})
|
||||
|
||||
it('produces empty test run result when there are no test cases in a nested testsuite element', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'empty', 'jest-junit-empty-testsuite.xml')
|
||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
|
||||
const opts: ParseOptions = {
|
||||
parseErrors: true,
|
||||
trackedFiles: []
|
||||
}
|
||||
|
||||
const parser = new JestJunitParser(opts)
|
||||
const result = await parser.parse(filePath, fileContent)
|
||||
expect(result.tests).toBe(0)
|
||||
expect(result.result).toBe('success')
|
||||
})
|
||||
|
||||
it('report from ./reports/jest test results matches snapshot', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'jest-junit.xml')
|
||||
const outputPath = path.join(__dirname, '__outputs__', 'jest-junit.md')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue