From d99f2e6e79fe7801073667f3f762304e513ffaf5 Mon Sep 17 00:00:00 2001 From: Ash Wilson Date: Wed, 6 Feb 2019 21:11:34 -0500 Subject: [PATCH] Subclass the Jasmine JUnit reporter to touch up the spec descriptions --- spec/jasmine-junit-reporter.js | 20 ++++++++++++++++++++ spec/jasmine-test-runner.coffee | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 spec/jasmine-junit-reporter.js diff --git a/spec/jasmine-junit-reporter.js b/spec/jasmine-junit-reporter.js new file mode 100644 index 000000000..19b31a54f --- /dev/null +++ b/spec/jasmine-junit-reporter.js @@ -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 } diff --git a/spec/jasmine-test-runner.coffee b/spec/jasmine-test-runner.coffee index bd881c178..200f03e38 100644 --- a/spec/jasmine-test-runner.coffee +++ b/spec/jasmine-test-runner.coffee @@ -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"