1
0
Fork 0
mirror of https://github.com/dorny/test-reporter.git synced 2026-02-04 05:27:55 +01:00

feat: Add listTestCaseTime flag to print test times next to test names

- Add a new listTestCaseTime flag, that optionally prints test times
next to test names. This flag defaults to false, for backward
compatibility.
- Update get-report.ts to use this flag when generating a report.
- Update existing tests to set ReportOptions listTestCaseTime: true to
verify above feature.
- Update README with documentation about this new flag.

Note this feature was needed for individual test times under pytest,
since the xml is generated with all tests under one test suite.

https://github.com/dorny/test-reporter/issues/260
This commit is contained in:
Rick Shanor 2026-01-06 07:39:38 -08:00
parent a810f9bf83
commit fb2dd2ba55
5 changed files with 31 additions and 7 deletions

View file

@ -3,7 +3,7 @@ import * as path from 'path'
import {JestJunitParser} from '../src/parsers/jest-junit/jest-junit-parser'
import {ParseOptions} from '../src/test-parser'
import {DEFAULT_OPTIONS, getReport} from '../src/report/get-report'
import {DEFAULT_OPTIONS, getReport, ReportOptions} from '../src/report/get-report'
import {normalizeFilePath} from '../src/utils/path-utils'
describe('jest-junit tests', () => {
@ -55,7 +55,12 @@ describe('jest-junit tests', () => {
const result = await parser.parse(filePath, fileContent)
expect(result).toMatchSnapshot()
const report = getReport([result])
const reportOpts: ReportOptions = {
...DEFAULT_OPTIONS,
listTestCaseTime: true
}
const report = getReport([result], reportOpts)
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
fs.writeFileSync(outputPath, report)
})