Subclass the Jasmine JUnit reporter to touch up the spec descriptions

This commit is contained in:
Ash Wilson
2019-02-06 21:11:34 -05:00
parent 8dfdccbb10
commit d99f2e6e79
2 changed files with 22 additions and 2 deletions

View File

@@ -0,0 +1,20 @@
require('jasmine-reporters')
class JasmineJUnitReporter extends jasmine.JUnitReporter {
fullDescription (spec) {
let fullDescription = spec.description
let currentSuite = spec.suite
while (currentSuite) {
fullDescription = currentSuite.description + ' ' + fullDescription
currentSuite = currentSuite.parentSuite
}
return fullDescription
}
reportSpecResults (spec) {
spec.description = this.fullDescription(spec)
return super.reportSpecResults(spec)
}
}
module.exports = { JasmineJUnitReporter }

View File

@@ -42,12 +42,12 @@ module.exports = ({logFile, headless, testPaths, buildAtomEnvironment}) ->
jasmineEnv.addReporter(new TimeReporter())
if process.env.TEST_JUNIT_XML_PATH
require 'jasmine-reporters'
{JasmineJUnitReporter} = require './jasmine-junit-reporter'
process.stdout.write "Outputting JUnit XML to <#{process.env.TEST_JUNIT_XML_PATH}>\n"
outputDir = path.dirname(process.env.TEST_JUNIT_XML_PATH)
fileBase = path.basename(process.env.TEST_JUNIT_XML_PATH, '.xml')
jasmineEnv.addReporter new jasmine.JUnitXmlReporter(outputDir, true, false, fileBase, true)
jasmineEnv.addReporter new JasmineJUnitReporter(outputDir, true, false, fileBase, true)
else
process.stdout.write "No JUnit XML\n"