mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-15 13:57: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>')
|
||||
})
|
||||
|
||||
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>')
|
||||
}
|
||||
expect(report).not.toContain('</details>')
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue