2015-03-17 09:55:49 +00:00
|
|
|
module.exports = function(module, reporter, options) {
|
2015-02-10 19:41:24 +00:00
|
|
|
if (typeof module !== "undefined" && module === require.main) {
|
|
|
|
if (typeof global.onload === "undefined")
|
|
|
|
global.onload = undefined;
|
|
|
|
var file = module.filename;
|
|
|
|
var Mocha = require("mocha");
|
2015-03-17 10:22:41 +00:00
|
|
|
var mocha = new Mocha(options || {});
|
2015-02-10 19:41:24 +00:00
|
|
|
mocha.reporter(reporter || "spec");
|
|
|
|
var suite = mocha.suite;
|
|
|
|
suite.emit('pre-require', global, file, mocha);
|
|
|
|
suite.emit('require', require(file), file, mocha);
|
|
|
|
setTimeout(function() {
|
|
|
|
suite.emit('post-require', global, file, mocha);
|
|
|
|
mocha.run(process.exit);
|
|
|
|
}, 0);
|
|
|
|
}
|
|
|
|
};
|