UNPKG

@jeli/dev-cli

Version:
22 lines (20 loc) 635 B
const Mocha = require('mocha'); const glob = require('glob'); const path = require('path'); module.exports = async function(projectDir, options) { // Instantiate a Mocha instance. const mocha = new Mocha(options); // Add each .spec.js file to the mocha instance glob.sync('**/*.spec.js', { cwd: projectDir, filter: 'isFile' }).forEach(function(file) { mocha.addFile( path.join(projectDir, file) ); }); // Run the tests. mocha.run(function(failures) { process.exitCode = failures ? 1 : 0; // exit with non-zero status if there were failures }); }