Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Merge pull request #1218 from jut-io/xunit-output-file

Travis Jeffery81d6b941e092
diff --cc bin/_mocha
index bcb1fb1d,37d6d566..c4900274
--- a/bin/_mocha
+++ b/bin/_mocha
@@@ -62,9 -62,9 +62,10 @@@ progra
.version(JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8')).version)
.usage('[debug] [options] [files]')
.option('-A, --async-only', "force all tests to take a callback (async)")
+ .option('-c, --colors', 'force enabling of colors')
.option('-C, --no-colors', 'force disabling of colors')
.option('-G, --growl', 'enable growl notification support')
+ .option('-O, --reporter-options <k=v,k2=v2,...>', 'reporter-specific options')
.option('-R, --reporter <name>', 'specify the reporter to use', 'spec')
.option('-S, --sort', "sort test files")
.option('-b, --bail', "bail after first test failure")
diff --cc lib/mocha.js
index 0835ba50,730229c3..27b45021
--- a/lib/mocha.js
+++ b/lib/mocha.js
@@@ -80,10 -69,9 +80,10 @@@ function Mocha(options)
this.suite = new exports.Suite('', new exports.Context);
this.ui(options.ui);
this.bail(options.bail);
- this.reporter(options.reporter);
+ this.reporter(options.reporter, options.reporterOptions);
if (null != options.timeout) this.timeout(options.timeout);
this.useColors(options.useColors)
+ if (options.enableTimeouts !== null) this.enableTimeouts(options.enableTimeouts);
if (options.slow) this.slow(options.slow);
this.suite.on('pre-require', function (context) {
@@@ -401,9 -365,16 +402,18 @@@ Mocha.prototype.run = function(fn)
if (options.grep) runner.grep(options.grep, options.invert);
if (options.globals) runner.globals(options.globals);
if (options.growl) this._growl(runner, reporter);
- exports.reporters.Base.useColors = options.useColors;
+ if (options.useColors !== undefined) {
+ exports.reporters.Base.useColors = options.useColors;
+ }
exports.reporters.Base.inlineDiffs = options.useInlineDiffs;
- return runner.run(fn);
+
+ function done(failures) {
+ if (reporter.done) {
+ reporter.done(failures, fn);
+ } else {
+ fn(failures);
+ }
+ }
+
+ return runner.run(done);
};