mirror of
https://github.com/dorny/test-reporter.git
synced 2026-02-01 10:55:23 -08:00
Previously we listed tests using markdown tables. Each test group had it's own table and textual preface saying how many tests were executed in what time. This was completely reworked - now tests are listed inside code block. Grouping is achieved using simple indentation. Duration of individual tests is no longer shown - it produced too much "noise" in the report. Pass/Fail check-mark was also moved before name of test suite. Behavior of "listTests" option was also changed - now if set to failed, it will list all tests, but only if suite is failed. Otherwise test listing is completely omitted. Last change affects report trimming - if report is still too big after "listTests" is set to "failed" - it will trim report to fit max size and add informational message at the end.
25 lines
871 B
TypeScript
25 lines
871 B
TypeScript
export function parseNetDuration(str: string): number {
|
|
const durationRe = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)$/
|
|
const durationMatch = str.match(durationRe)
|
|
if (durationMatch === null) {
|
|
throw new Error(`Invalid format: "${str}" is not NET duration`)
|
|
}
|
|
|
|
const [_, hourStr, minStr, secStr] = durationMatch
|
|
return (parseInt(hourStr) * 3600 + parseInt(minStr) * 60 + parseFloat(secStr)) * 1000
|
|
}
|
|
|
|
export function parseIsoDate(str: string): Date {
|
|
const isoDateRe = /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)$/
|
|
if (str === undefined || !isoDateRe.test(str)) {
|
|
throw new Error(`Invalid format: "${str}" is not ISO date`)
|
|
}
|
|
|
|
return new Date(str)
|
|
}
|
|
|
|
export function getFirstNonEmptyLine(stackTrace: string): string | undefined {
|
|
const lines = stackTrace.split(/\r?\n/g)
|
|
return lines.find(str => !/^\s*$/.test(str))
|
|
}
|