mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-15 22:07:09 +01:00
jest-junit - use milliseconds for test suites times
This commit is contained in:
parent
9b620ef56a
commit
e169ffb719
2 changed files with 11 additions and 8 deletions
|
|
@ -76,8 +76,8 @@ Received: false
|
|||
"summary": "**6** tests were completed in **1.360s** with **1** passed, **1** skipped and **4** failed.
|
||||
| Result | Suite | Tests | Time | Passed ✔️ | Failed ❌ | Skipped ✖️ |
|
||||
| :---: | :--- | ---: | ---: | ---: | ---: | ---: |
|
||||
| ❌ | [__tests__\\\\main.test.js](#ts-0-tests-main-test-js) | 4 | 0.486s | 1 | 3 | 0 |
|
||||
| ❌ | [__tests__\\\\second.test.js](#ts-1-tests-second-test-js) | 2 | 0.082s | 0 | 1 | 1 |
|
||||
| ❌ | [__tests__\\\\main.test.js](#ts-0-tests-main-test-js) | 4 | 486ms | 1 | 3 | 0 |
|
||||
| ❌ | [__tests__\\\\second.test.js](#ts-1-tests-second-test-js) | 2 | 82ms | 0 | 1 | 1 |
|
||||
# Test Suites
|
||||
|
||||
## <a id=\\"user-content-ts-0-tests-main-test-js\\" href=\\"#ts-0-tests-main-test-js\\">__tests__\\\\main.test.js</a> ❌
|
||||
|
|
|
|||
|
|
@ -19,17 +19,16 @@ export async function parseJestJunit(content: string, options: ParseOptions): Pr
|
|||
success,
|
||||
output: {
|
||||
title: `${junit.testsuites.$.name.trim()} ${icon}`,
|
||||
summary: getSummary(success, junit),
|
||||
summary: getSummary(junit),
|
||||
annotations: options.annotations ? getAnnotations(junit, options.workDir, options.trackedFiles) : undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getSummary(success: boolean, junit: JunitReport): string {
|
||||
function getSummary(junit: JunitReport): string {
|
||||
const stats = junit.testsuites.$
|
||||
|
||||
const time = `${stats.time.toFixed(3)}s`
|
||||
|
||||
const skipped = getSkippedCount(junit.testsuites)
|
||||
const failed = stats.errors + stats.failures
|
||||
const passed = stats.tests - failed - skipped
|
||||
|
|
@ -40,8 +39,8 @@ function getSummary(success: boolean, junit: JunitReport): string {
|
|||
const skip = ts.$.skipped
|
||||
const fail = ts.$.errors + ts.$.failures
|
||||
const pass = ts.$.tests - fail - skip
|
||||
const tm = `${ts.$.time.toFixed(3)}s`
|
||||
const result = success ? Icon.success : Icon.fail
|
||||
const tm = formatTime(ts.$.time)
|
||||
const result = fail === 0 ? Icon.success : Icon.fail
|
||||
const tsName = ts.$.name.trim()
|
||||
const tsAddr = makeSuiteSlug(i, tsName).link
|
||||
const tsNameLink = link(tsName, tsAddr)
|
||||
|
|
@ -86,7 +85,7 @@ function getSuiteSummary(suite: TestSuite, index: number): string {
|
|||
[Align.Center, Align.Left, Align.Right],
|
||||
...grp.tests.map(tc => {
|
||||
const name = tc.$.name.trim()
|
||||
const time = `${Math.round(tc.$.time * 1000)}ms`
|
||||
const time = formatTime(tc.$.time)
|
||||
const result = getTestCaseIcon(tc)
|
||||
return [result, name, time]
|
||||
})
|
||||
|
|
@ -113,6 +112,10 @@ function makeSuiteSlug(index: number, name: string): {id: string; link: string}
|
|||
return slug(`ts-${index}-${name}`)
|
||||
}
|
||||
|
||||
function formatTime(sec: number): string {
|
||||
return `${Math.round(sec * 1000)}ms`
|
||||
}
|
||||
|
||||
function getAnnotations(junit: JunitReport, workDir: string, trackedFiles: string[]): Annotation[] {
|
||||
const annotations: Annotation[] = []
|
||||
for (const suite of junit.testsuites.testsuite) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue