mirror of
https://github.com/dorny/test-reporter.git
synced 2026-02-04 13:37:56 +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:
parent
a810f9bf83
commit
fb2dd2ba55
5 changed files with 31 additions and 7 deletions
|
|
@ -11,6 +11,7 @@ const MAX_ACTIONS_SUMMARY_LENGTH = 1048576
|
|||
export interface ReportOptions {
|
||||
listSuites: 'all' | 'failed' | 'none'
|
||||
listTests: 'all' | 'failed' | 'none'
|
||||
listTestCaseTime: boolean
|
||||
baseUrl: string
|
||||
onlySummary: boolean
|
||||
useActionsSummary: boolean
|
||||
|
|
@ -22,6 +23,7 @@ export interface ReportOptions {
|
|||
export const DEFAULT_OPTIONS: ReportOptions = {
|
||||
listSuites: 'all',
|
||||
listTests: 'all',
|
||||
listTestCaseTime: false,
|
||||
baseUrl: '',
|
||||
onlySummary: false,
|
||||
useActionsSummary: true,
|
||||
|
|
@ -281,7 +283,8 @@ function getTestsReport(ts: TestSuiteResult, runIndex: number, suiteIndex: numbe
|
|||
continue
|
||||
}
|
||||
const result = getResultIcon(tc.result)
|
||||
sections.push(`${space}${result} ${tc.name}`)
|
||||
const time = options.listTestCaseTime && tc.time ? ` (${formatTime(tc.time)})` : ''
|
||||
sections.push(`${space}${result} ${tc.name}${time}`)
|
||||
if (tc.error) {
|
||||
const lines = (tc.error.message ?? getFirstNonEmptyLine(tc.error.details)?.trim())
|
||||
?.split(/\r?\n/g)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue