From 430af80d4c5d53d948c496f394593c08c62f8247 Mon Sep 17 00:00:00 2001 From: juergba Date: Thu, 14 Mar 2019 19:18:14 +0100 Subject: [PATCH] Instantiate Runner earlier in Mocha constructor --- lib/mocha.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/mocha.js b/lib/mocha.js index aab5604448..5c174cc7e1 100644 --- a/lib/mocha.js +++ b/lib/mocha.js @@ -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 || {}); @@ -153,6 +155,8 @@ function Mocha(options) { this[opt](); } }, this); + + this.runner = new exports.Runner(this.suite, options.delay); } /** @@ -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;