mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-15 22:07:09 +01:00
tests: refactor input collapsed=auto to individual tests
Generated-by: Claude Sonnet 4.5
This commit is contained in:
parent
c7935221e6
commit
cd299561e7
1 changed files with 34 additions and 12 deletions
|
|
@ -250,8 +250,35 @@ describe('jest-junit tests', () => {
|
||||||
expect(report).not.toContain('</details>')
|
expect(report).not.toContain('</details>')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('report auto-collapses only when all tests pass', async () => {
|
it('report auto-collapses when all tests pass', async () => {
|
||||||
// Test with a fixture that has passing tests (no failures)
|
// Test with a fixture that has all passing tests (no failures)
|
||||||
|
const fixturePath = path.join(__dirname, 'fixtures', 'jest-junit-eslint.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)
|
||||||
|
|
||||||
|
// Verify this fixture has no failures
|
||||||
|
expect(result.failed).toBe(0)
|
||||||
|
|
||||||
|
const report = getReport([result], {
|
||||||
|
...DEFAULT_OPTIONS,
|
||||||
|
collapsed: 'auto'
|
||||||
|
})
|
||||||
|
|
||||||
|
// Should collapse when all tests pass
|
||||||
|
expect(report).toContain('<details><summary>Expand for details</summary>')
|
||||||
|
expect(report).toContain('</details>')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('report does not auto-collapse when tests fail', async () => {
|
||||||
|
// Test with a fixture that has failing tests
|
||||||
const fixturePath = path.join(__dirname, 'fixtures', 'jest-junit.xml')
|
const fixturePath = path.join(__dirname, 'fixtures', 'jest-junit.xml')
|
||||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||||
|
|
@ -264,21 +291,16 @@ describe('jest-junit tests', () => {
|
||||||
const parser = new JestJunitParser(opts)
|
const parser = new JestJunitParser(opts)
|
||||||
const result = await parser.parse(filePath, fileContent)
|
const result = await parser.parse(filePath, fileContent)
|
||||||
|
|
||||||
// Check if this fixture has failures to determine expected behavior
|
// Verify this fixture has failures
|
||||||
const hasFailed = result.failed > 0
|
expect(result.failed).toBeGreaterThan(0)
|
||||||
|
|
||||||
const report = getReport([result], {
|
const report = getReport([result], {
|
||||||
...DEFAULT_OPTIONS,
|
...DEFAULT_OPTIONS,
|
||||||
collapsed: 'auto'
|
collapsed: 'auto'
|
||||||
})
|
})
|
||||||
|
|
||||||
if (hasFailed) {
|
// Should not collapse when there are failures
|
||||||
// Should not collapse when there are failures
|
expect(report).not.toContain('<details><summary>Expand for details</summary>')
|
||||||
expect(report).not.toContain('<details><summary>Expand for details</summary>')
|
expect(report).not.toContain('</details>')
|
||||||
} else {
|
|
||||||
// Should collapse when all tests pass
|
|
||||||
expect(report).toContain('<details><summary>Expand for details</summary>')
|
|
||||||
expect(report).toContain('</details>')
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue