Skip to content

Commit

Permalink
Update dist/index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Dorner committed Jan 29, 2021
1 parent c75a9dd commit 07a0223
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 75 deletions.
163 changes: 101 additions & 62 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

25 changes: 14 additions & 11 deletions src/report/get-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,16 @@ function getReportBadge(results: TestRunResult[]): string {

function getBadge(passed: number, failed: number, skipped: number): string {
const text = []
if (passed > 0) { text.push(`${passed} passed`) }
if (failed > 0) { text.push(`${failed} failed`) }
if (skipped > 0) { text.push(`${skipped} skipped`) }
let message = text.length > 0 ? text.join(', ') : 'none'
if (passed > 0) {
text.push(`${passed} passed`)
}
if (failed > 0) {
text.push(`${failed} failed`)
}
if (skipped > 0) {
text.push(`${skipped} skipped`)
}
const message = text.length > 0 ? text.join(', ') : 'none'

let color = 'success'
if (failed > 0) {
Expand Down Expand Up @@ -101,13 +107,12 @@ function getTestRunsReport(testRuns: TestRunResult[], options: ReportOptions): s
function getSuitesReport(tr: TestRunResult, runIndex: number, options: ReportOptions): string[] {
const sections: string[] = []

const time = `${(tr.time / 1000).toFixed(3)}s`

const slug = makeRunSlug(runIndex)
const nameLink = `<a id="${slug.id}" href="${slug.link}">${tr.path}</a>`
const trSlug = makeRunSlug(runIndex)
const nameLink = `<a id="${trSlug.id}" href="${trSlug.link}">${tr.path}</a>`
const icon = getResultIcon(tr.result)
sections.push(`## ${nameLink} ${icon}`)

const time = `${(tr.time / 1000).toFixed(3)}s`
const headingLine2 = `**${tr.tests}** tests were completed in **${time}** with **${tr.passed}** passed, **${tr.failed}** failed and **${tr.skipped}** skipped.`
sections.push(headingLine2)

Expand All @@ -132,9 +137,7 @@ function getSuitesReport(tr: TestRunResult, runIndex: number, options: ReportOpt
}

if (options.listTests !== 'none') {
const tests = suites
.map((ts, suiteIndex) => getTestsReport(ts, runIndex, suiteIndex, options))
.flat()
const tests = suites.map((ts, suiteIndex) => getTestsReport(ts, runIndex, suiteIndex, options)).flat()

if (tests.length > 1) {
sections.push(...tests)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/markdown-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function ellipsis(text: string, maxLength: number): string {
return text.substr(0, maxLength - 3) + '...'
}

export function formatTime(ms: number) {
export function formatTime(ms: number): string {
if (ms > 1000) {
return `${(ms / 1000).toFixed(3)}s`
}
Expand Down

0 comments on commit 07a0223

Please sign in to comment.