Skip to content

Commit 430af80

Browse files
committed
Instantiate Runner earlier in Mocha constructor
1 parent d1024a3 commit 430af80

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/mocha.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ exports.Test = require('./test');
9191
* @param {string} [options.ui] - Interface name.
9292
* @param {boolean} [options.color] - Color TTY output from reporter?
9393
* @param {boolean} [options.useInlineDiffs] - Use inline diffs?
94+
* @prop {Suite} suite - Root Suite instance
95+
* @prop {Runner} runner - Runner instance
9496
*/
9597
function Mocha(options) {
9698
options = utils.assign({}, mocharc, options || {});
@@ -153,6 +155,8 @@ function Mocha(options) {
153155
this[opt]();
154156
}
155157
}, this);
158+
159+
this.runner = new exports.Runner(this.suite, options.delay);
156160
}
157161

158162
/**
@@ -803,10 +807,9 @@ Mocha.prototype.run = function(fn) {
803807
if (this.files.length) {
804808
this.loadFiles();
805809
}
806-
var suite = this.suite;
807810
var options = this.options;
808811
options.files = this.files;
809-
var runner = new exports.Runner(suite, options.delay);
812+
var runner = this.runner;
810813
createStatsCollector(runner);
811814
var reporter = new this._reporter(runner, options);
812815
runner.ignoreLeaks = options.ignoreLeaks !== false;

0 commit comments

Comments
 (0)