diff --git a/lib/runner.js b/lib/runner.js index 3e978ccece..12807725fb 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -135,27 +135,15 @@ class Runner extends EventEmitter { * @public * @class * @param {Suite} suite - Root suite - * @param {Object|boolean} [opts] - Options. If `boolean` (deprecated), whether to delay execution of root suite until ready. + * @param {Object} [opts] - Settings object * @param {boolean} [opts.cleanReferencesAfterRun] - Whether to clean references to test fns and hooks when a suite is done. * @param {boolean} [opts.delay] - Whether to delay execution of root suite until ready. * @param {boolean} [opts.dryRun] - Whether to report tests without running them. * @param {boolean} [opts.failZero] - Whether to fail test run if zero tests encountered. */ - constructor(suite, opts) { + constructor(suite, opts = {}) { super(); - if (opts === undefined) { - opts = {}; - } - if (typeof opts === 'boolean') { - // TODO: remove this - require('./errors').deprecate( - '"Runner(suite: Suite, delay: boolean)" is deprecated. Use "Runner(suite: Suite, {delay: boolean})" instead.' - ); - this._delay = opts; - opts = {}; - } else { - this._delay = opts.delay; - } + var self = this; this._globals = []; this._abort = false; @@ -1066,7 +1054,7 @@ Runner.prototype.run = function (fn, opts = {}) { debug('run(): filtered exclusive Runnables'); } this.state = constants.STATE_RUNNING; - if (this._delay) { + if (this._opts.delay) { this.emit(constants.EVENT_DELAY_END); debug('run(): "delay" ended'); } @@ -1093,7 +1081,7 @@ Runner.prototype.run = function (fn, opts = {}) { this._addEventListener(process, 'uncaughtException', this.uncaught); this._addEventListener(process, 'unhandledRejection', this.unhandled); - if (this._delay) { + if (this._opts.delay) { // for reporters, I guess. // might be nice to debounce some dots while we wait. this.emit(constants.EVENT_DELAY_BEGIN, rootSuite); diff --git a/test/unit/runner.spec.js b/test/unit/runner.spec.js index 9c8a3016e6..dd96558017 100644 --- a/test/unit/runner.spec.js +++ b/test/unit/runner.spec.js @@ -8,7 +8,6 @@ const {Suite, Runner, Test, Hook, Runnable} = Mocha; const {noop} = Mocha.utils; const {FATAL, MULTIPLE_DONE, UNSUPPORTED} = require('../../lib/errors').constants; -const errors = require('../../lib/errors'); const { EVENT_HOOK_BEGIN, @@ -30,15 +29,6 @@ describe('Runner', function () { sinon.restore(); }); - describe('constructor deprecation', function () { - it('should print a deprecation warning', function () { - sinon.stub(errors, 'deprecate'); - const suite = new Suite('Suite', 'root'); - new Runner(suite, false); /* eslint no-new: "off" */ - expect(errors.deprecate, 'was called once'); - }); - }); - describe('instance method', function () { let suite; let runner;