Skip to content

Commit

Permalink
fix: handle gathering count of skipped tests when suite doesn't provi…
Browse files Browse the repository at this point in the history
…de count
  • Loading branch information
sgtcoolguy committed Sep 19, 2019
1 parent e2891a0 commit 69c5dfb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,17 @@ function reportSummary(suites: Element[]): void {
results.count += s.hasAttribute("tests") ? parseInt(s.getAttribute("tests"), 10) : 0
results.failures += s.hasAttribute("failures") ? parseInt(s.getAttribute("failures"), 10) : 0
results.failures += s.hasAttribute("errors") ? parseInt(s.getAttribute("errors"), 10) : 0
results.skipped += s.hasAttribute("skipped") ? parseInt(s.getAttribute("skipped"), 10) : 0
results.skipped += s.hasAttribute("skipped") ? parseInt(s.getAttribute("skipped"), 10) : gatherSkipped(s)
})

if (results.failures !== 0) {
message(`:x: ${results.failures} tests have failed
There are ${results.failures} tests failing and ${results.skipped} skipped out of ${results.count} total tests.`)
} else {
let msg = `:white_check_mark: All tests are passing
Nice one! All ${results.count} tests are passing.`
Nice one! All ${results.count - results.skipped} tests are passing.`
if (results.skipped !== 0) {
msg += `\n(There are ${results.skipped} tests skipped)`
msg += `\n(There are ${results.skipped} skipped tests not included in that total)`
}
message(msg)
}
Expand Down Expand Up @@ -195,3 +195,10 @@ function gatherFailedTestcases(suites: Element[]): Element[] {
)
})
}

function gatherSkipped(suite: Element): number {
const testcases: Element[] = Array.from(suite.getElementsByTagName("testcase"))
return testcases.filter(test => {
return test.hasChildNodes() && test.getElementsByTagName("skipped").length > 0
}).length
}

0 comments on commit 69c5dfb

Please sign in to comment.