mocha.run(function() { console.log = originalLog; Mocha.reporters.Base.useColors = previousUseColors; resolve(logs.join('\n')); });
server.serve('test') .then(function (app) { appToReturn = app; mocha.ui('bdd').run(code => { process.exit(code) }); // exit the node process on test end }) .catch('Failed to start test server.');
// add all spec files to mocha recursive(SPEC_SOURCE_DIR, function (err, files) { if (err) { console.error(err); return exit(1); } var mocha = new Mocha({timeout: 1000 * 60}); // specially load bootstrap file mocha.addFile(path.join(SPEC_SOURCE_DIR, '_bootstrap.js')); files.filter(function (file) { // extract all test files return (file.substr(-8) === '.test.js'); }).forEach(mocha.addFile.bind(mocha)); mocha.run(function (err) { err && console.error(err.stack || err); exit(err ? 1 : 0); }); });
function execute() { return new Promise((resolve) => { mocha.run((failures) => { if (failures === 0) return resolve(); process.on('exit', () => process.exit(failures)); }); }); }
async function run() { if (config.general.environment.toLowerCase() === 'production') { log.info('Tests should not be run in Production mode, it affects your configured database') log.info('If you know what you are doing, set config.general.environment to "Test" first') process.exit() } const tests = await getFiles(`${__dirname}/tests`) tests.filter((file) => file.substr(-3) === '.js').forEach((filePath) => mocha.addFile(filePath)) mocha.run((failures) => { process.exitCode = failures ? 1 : 0 process.exit() }) }
/* istanbul ignore next */ mocha.run(function(failures) { process.on('exit', function() { process.exit(failures); }); process.exit(); });
mocha.run() .on('test', function(test) { console.log('Test started: ' + test.title); }) .on('test end', function(test) { console.log('Test ended: ' + test.title); }) .on('pass', function(test) { console.log('Test passed'); }) .on('fail', function(test, err) { console.log('Test failed'); console.log(test); console.log(err); }) .on('end', function() { console.log('All tests done'); });
let runner = mocha.run(function (failures) { process.exitCode = failures ? 1 : 0; // exit with non-zero status if there were failures });
mocha.run(failures => { if (failures > 0) { e(new Error(`${failures} tests failed.`));
mocha.run(function (failures) { process.exit(failures); });
}) mocha.run(function(failures) { helpers.debug('MOCHA: Completed run') if(failures && failures>0) {
// Run mocha mocha.run(failures => { process.on('exit', () => { process.exit(failures); }); });
mocha.run(function(failureCount) { process.on("exit", function() { process.exit(failureCount); }); });
// FUNCTION: Run all tests function RUN_ALL() { MochaInstanceAll.run(function(failures) { process.on('exit', function() { process.exit(failures); }); }); }