Configure Mocha to use the JUnit XML reporter

This commit is contained in:
Ash Wilson
2017-08-01 09:02:44 -04:00
parent 8ea491f223
commit 41cb5ce076

View File

@@ -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)) {