From 41cb5ce07665b0eab12486292ad734cd3cabc54a Mon Sep 17 00:00:00 2001 From: Ash Wilson Date: Tue, 1 Aug 2017 09:02:44 -0400 Subject: [PATCH] Configure Mocha to use the JUnit XML reporter --- spec/main-process/mocha-test-runner.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/spec/main-process/mocha-test-runner.js b/spec/main-process/mocha-test-runner.js index 0fe5a5125..d1634fd72 100644 --- a/spec/main-process/mocha-test-runner.js +++ b/spec/main-process/mocha-test-runner.js @@ -7,7 +7,24 @@ import {assert} from 'chai' export default function (testPaths) { global.assert = assert - const mocha = new Mocha({reporter: 'spec'}) + let reporterOptions = { + reporterEnabled: 'list' + } + + if (process.env.TEST_JUNIT_XML_PATH) { + console.log(`Mocha: Producing JUnit XML output at ${process.env.TEST_JUNIT_XML_PATH}.`) + reporterOptions = { + reporterEnabled: 'list, mocha-junit-reporter', + mochaJunitReporterReporterOptions: { + mochaFile: process.env.TEST_JUNIT_XML_PATH + } + } + } + + const mocha = new Mocha({ + reporter: 'mocha-multi-reporters', + reporterOptions + }) for (let testPath of testPaths) { if (fs.isDirectorySync(testPath)) { for (let testFilePath of fs.listTreeSync(testPath)) {