Fix edge case of one test assembly

This commit is contained in:
Ray Xu 2022-05-06 04:34:02 +00:00 committed by Zach Renner
parent 3608ee03fd
commit 724497a84c
14 changed files with 65 additions and 6 deletions

View file

@ -143,8 +143,13 @@ function getBadge(passed: number, failed: number, skipped: number, options: Repo
function getTestRunsReport(testRuns: TestRunResult[], options: ReportOptions): string[] {
const sections: string[] = []
const totalFailed = testRuns.reduce((sum, tr) => sum + tr.failed, 0)
if (totalFailed === 0) {
sections.push(`<details><summary>Expand for details</summary>`)
sections.push(` `)
}
if (testRuns.length > 1 || options.onlySummary) {
if (testRuns.length > 0 || options.onlySummary) {
const tableData = testRuns
.filter(tr => tr.passed > 0 || tr.failed > 0 || tr.skipped > 0)
.map(tr => {
@ -168,6 +173,10 @@ function getTestRunsReport(testRuns: TestRunResult[], options: ReportOptions): s
const suitesReports = testRuns.map((tr, i) => getSuitesReport(tr, i, options)).flat()
sections.push(...suitesReports)
}
if (totalFailed === 0) {
sections.push(`</details>`)
}
return sections
}