Skip to content

Commit b7b849b

Browse files
authored
refactor!: remove deprecated Runner signature (#4861)
1 parent 0608fa3 commit b7b849b

File tree

2 files changed

+5
-27
lines changed

2 files changed

+5
-27
lines changed

lib/runner.js

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -135,27 +135,15 @@ class Runner extends EventEmitter {
135135
* @public
136136
* @class
137137
* @param {Suite} suite - Root suite
138-
* @param {Object|boolean} [opts] - Options. If `boolean` (deprecated), whether to delay execution of root suite until ready.
138+
* @param {Object} [opts] - Settings object
139139
* @param {boolean} [opts.cleanReferencesAfterRun] - Whether to clean references to test fns and hooks when a suite is done.
140140
* @param {boolean} [opts.delay] - Whether to delay execution of root suite until ready.
141141
* @param {boolean} [opts.dryRun] - Whether to report tests without running them.
142142
* @param {boolean} [opts.failZero] - Whether to fail test run if zero tests encountered.
143143
*/
144-
constructor(suite, opts) {
144+
constructor(suite, opts = {}) {
145145
super();
146-
if (opts === undefined) {
147-
opts = {};
148-
}
149-
if (typeof opts === 'boolean') {
150-
// TODO: remove this
151-
require('./errors').deprecate(
152-
'"Runner(suite: Suite, delay: boolean)" is deprecated. Use "Runner(suite: Suite, {delay: boolean})" instead.'
153-
);
154-
this._delay = opts;
155-
opts = {};
156-
} else {
157-
this._delay = opts.delay;
158-
}
146+
159147
var self = this;
160148
this._globals = [];
161149
this._abort = false;
@@ -1066,7 +1054,7 @@ Runner.prototype.run = function (fn, opts = {}) {
10661054
debug('run(): filtered exclusive Runnables');
10671055
}
10681056
this.state = constants.STATE_RUNNING;
1069-
if (this._delay) {
1057+
if (this._opts.delay) {
10701058
this.emit(constants.EVENT_DELAY_END);
10711059
debug('run(): "delay" ended');
10721060
}
@@ -1093,7 +1081,7 @@ Runner.prototype.run = function (fn, opts = {}) {
10931081
this._addEventListener(process, 'uncaughtException', this.uncaught);
10941082
this._addEventListener(process, 'unhandledRejection', this.unhandled);
10951083

1096-
if (this._delay) {
1084+
if (this._opts.delay) {
10971085
// for reporters, I guess.
10981086
// might be nice to debounce some dots while we wait.
10991087
this.emit(constants.EVENT_DELAY_BEGIN, rootSuite);

test/unit/runner.spec.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const {Suite, Runner, Test, Hook, Runnable} = Mocha;
88
const {noop} = Mocha.utils;
99
const {FATAL, MULTIPLE_DONE, UNSUPPORTED} =
1010
require('../../lib/errors').constants;
11-
const errors = require('../../lib/errors');
1211

1312
const {
1413
EVENT_HOOK_BEGIN,
@@ -30,15 +29,6 @@ describe('Runner', function () {
3029
sinon.restore();
3130
});
3231

33-
describe('constructor deprecation', function () {
34-
it('should print a deprecation warning', function () {
35-
sinon.stub(errors, 'deprecate');
36-
const suite = new Suite('Suite', 'root');
37-
new Runner(suite, false); /* eslint no-new: "off" */
38-
expect(errors.deprecate, 'was called once');
39-
});
40-
});
41-
4232
describe('instance method', function () {
4333
let suite;
4434
let runner;

0 commit comments

Comments
 (0)