mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-15 13:57:09 +01:00
Fix short summary formatting when a report title is present
This commit is contained in:
parent
eeac280b8e
commit
6617053f9c
3 changed files with 70 additions and 17 deletions
|
|
@ -303,4 +303,47 @@ describe('jest-junit tests', () => {
|
|||
expect(report).not.toContain('<details><summary>Expand for details</summary>')
|
||||
expect(report).not.toContain('</details>')
|
||||
})
|
||||
|
||||
it('report includes the short summary', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'jest-junit.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)
|
||||
const shortSummary = '1 passed, 4 failed and 1 skipped'
|
||||
const report = getReport([result], DEFAULT_OPTIONS, shortSummary)
|
||||
// Report should have the title as the first line
|
||||
expect(report).toMatch(/^## 1 passed, 4 failed and 1 skipped\n/)
|
||||
})
|
||||
|
||||
it('report includes a custom report title and short summary', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'jest-junit.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)
|
||||
const shortSummary = '1 passed, 4 failed and 1 skipped'
|
||||
const report = getReport(
|
||||
[result],
|
||||
{
|
||||
...DEFAULT_OPTIONS,
|
||||
reportTitle: 'My Custom Title'
|
||||
},
|
||||
shortSummary
|
||||
)
|
||||
// Report should have the title as the first line
|
||||
expect(report).toMatch(/^# My Custom Title\n## 1 passed, 4 failed and 1 skipped\n/)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue