Skip to content

Commit 9872410

Browse files
authored
Deprecate "Runner(suite: Suite, delay: boolean)" (#4646)
1 parent a93d759 commit 9872410

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/runner.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class Runner extends EventEmitter {
138138
* @public
139139
* @class
140140
* @param {Suite} suite - Root suite
141-
* @param {Object|boolean} [opts] - Options. If `boolean`, whether or not to delay execution of root suite until ready (for backwards compatibility).
141+
* @param {Object|boolean} [opts] - Options. If `boolean` (deprecated), whether or not to delay execution of root suite until ready.
142142
* @param {boolean} [opts.delay] - Whether to delay execution of root suite until ready.
143143
* @param {boolean} [opts.cleanReferencesAfterRun] - Whether to clean references to test fns and hooks when a suite is done.
144144
*/
@@ -148,7 +148,10 @@ class Runner extends EventEmitter {
148148
opts = {};
149149
}
150150
if (typeof opts === 'boolean') {
151-
// TODO: deprecate this
151+
// TODO: remove this
152+
require('./errors').deprecate(
153+
'"Runner(suite: Suite, delay: boolean)" is deprecated. Use "Runner(suite: Suite, {delay: boolean})" instead.'
154+
);
152155
this._delay = opts;
153156
opts = {};
154157
} else {

test/unit/runner.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const {
1111
MULTIPLE_DONE,
1212
UNSUPPORTED
1313
} = require('../../lib/errors').constants;
14+
const errors = require('../../lib/errors');
1415

1516
const {
1617
EVENT_HOOK_BEGIN,
@@ -32,6 +33,15 @@ describe('Runner', function() {
3233
sinon.restore();
3334
});
3435

36+
describe('constructor deprecation', function() {
37+
it('should print a deprecation warning', function() {
38+
sinon.stub(errors, 'deprecate');
39+
const suite = new Suite('Suite', 'root');
40+
new Runner(suite, false); /* eslint no-new: "off" */
41+
expect(errors.deprecate, 'was called once');
42+
});
43+
});
44+
3545
describe('instance method', function() {
3646
let suite;
3747
let runner;

0 commit comments

Comments
 (0)