tests: refactor input collapsed=auto to individual tests

Generated-by: Claude Sonnet 4.5
This commit is contained in:
Jozef Izso 2025-11-12 14:20:54 +01:00
parent c7935221e6
commit cd299561e7
Failed to extract signature

View file

@ -250,8 +250,35 @@ describe('jest-junit tests', () => {
expect(report).not.toContain('</details>')
})
it('report auto-collapses only when all tests pass', async () => {
// Test with a fixture that has passing tests (no failures)
it('report auto-collapses when all tests pass', async () => {
// 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 filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
@ -264,21 +291,16 @@ describe('jest-junit tests', () => {
const parser = new JestJunitParser(opts)
const result = await parser.parse(filePath, fileContent)
// Check if this fixture has failures to determine expected behavior
const hasFailed = result.failed > 0
// Verify this fixture has failures
expect(result.failed).toBeGreaterThan(0)
const report = getReport([result], {
...DEFAULT_OPTIONS,
collapsed: 'auto'
})
if (hasFailed) {
// Should not collapse when there are failures
expect(report).not.toContain('<details><summary>Expand for details</summary>')
} else {
// Should collapse when all tests pass
expect(report).toContain('<details><summary>Expand for details</summary>')
expect(report).toContain('</details>')
}
// Should not collapse when there are failures
expect(report).not.toContain('<details><summary>Expand for details</summary>')
expect(report).not.toContain('</details>')
})
})