Files
atom/spec/main-process/mocha-test-runner.js
Ash Wilson e90441303d 🔥 console.logs
2017-08-02 19:34:44 -04:00

47 lines
972 B
JavaScript

"use babel"
import Mocha from 'mocha'
import fs from 'fs-plus'
import {assert} from 'chai'
export default function (testPaths) {
global.assert = assert
let reporterOptions = {
reporterEnabled: 'list'
}
if (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)) {
if (/\.test\.(coffee|js)$/.test(testFilePath)) {
mocha.addFile(testFilePath)
}
}
} else {
mocha.addFile(testPath)
}
}
mocha.run(function (failures) {
if (failures === 0) {
process.exit(0)
} else {
process.exit(1)
}
})
}