Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 4x 4x 2x 2x 1x 1x 2x 2x 4x 2x 6x 6x 6x 4x 1x | const fs = require('fs')
const statusPassed = 'passed'
const statusFailed = 'failed'
const markPassed = ':white_check_mark:'
const markFailed = ':x:'
const outputFile = process.env.JEST_OUTPUT_FILENAME || 'test-result.json'
// Processes jest test results and saves them to a file.
// See https://gimpneek.github.io/jest-reporter-debug/DocumentTestHooksReporter.html
class SmokeTestReporter {
constructor(globalConfig, options) {
this._globalConfig = globalConfig
this._options = options
Eif (!options) {
options = {}
}
this.markPassed = options.markPassed || markPassed
this.markFailed = options.markFailed || markFailed
}
async onRunComplete(test, runResults) {
const summary = this.getSummary(runResults)
await fs.writeFile(outputFile, JSON.stringify(summary))
}
getSummary(runResults) {
const testResults = new Map()
// Go over all test cases and grab their descriptions
const testSuiteResults = runResults.testResults
const testCaseResults = [].concat.apply([], testSuiteResults.map(test => test.testResults))
testCaseResults.forEach(testCase => {
const testPassed = testCase.status !== statusFailed
testResults.set(testCase.title, testPassed)
})
let result = {}
if (this.allTestsPassed(runResults)) {
result.status = statusPassed
} else {
result.status = statusFailed
}
result.tests = ''
testResults.forEach((isPassed, test) => {
result.tests += `${this.getTestMark(isPassed)} ${test}\n`
})
return result
}
allTestsPassed(runResults) {
const noTestsFailed = 0 === runResults.numFailedTests
const noTestSuitesFailed = 0 === runResults.numFailedTestSuites
return noTestsFailed && noTestSuitesFailed
}
getTestMark(isPassed) {
return isPassed ? this.markPassed : this.markFailed
}
}
module.exports = SmokeTestReporter
|