Skip to content

Commit

Permalink
Instantiate Runner earlier in Mocha constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Mar 15, 2019
1 parent d1024a3 commit 430af80
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ exports.Test = require('./test');
* @param {string} [options.ui] - Interface name.
* @param {boolean} [options.color] - Color TTY output from reporter?
* @param {boolean} [options.useInlineDiffs] - Use inline diffs?
* @prop {Suite} suite - Root Suite instance
* @prop {Runner} runner - Runner instance
*/
function Mocha(options) {
options = utils.assign({}, mocharc, options || {});
Expand Down Expand Up @@ -153,6 +155,8 @@ function Mocha(options) {
this[opt]();
}
}, this);

this.runner = new exports.Runner(this.suite, options.delay);
}

/**
Expand Down Expand Up @@ -803,10 +807,9 @@ Mocha.prototype.run = function(fn) {
if (this.files.length) {
this.loadFiles();
}
var suite = this.suite;
var options = this.options;
options.files = this.files;
var runner = new exports.Runner(suite, options.delay);
var runner = this.runner;
createStatsCollector(runner);
var reporter = new this._reporter(runner, options);
runner.ignoreLeaks = options.ignoreLeaks !== false;
Expand Down

0 comments on commit 430af80

Please sign in to comment.