Skip to content

Commit

Permalink
Deprecate "Runner(suite: Suite, delay: boolean)" (#4646)
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Jun 4, 2021
1 parent a93d759 commit 9872410
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/runner.js
Expand Up @@ -138,7 +138,7 @@ class Runner extends EventEmitter {
* @public
* @class
* @param {Suite} suite - Root suite
* @param {Object|boolean} [opts] - Options. If `boolean`, whether or not to delay execution of root suite until ready (for backwards compatibility).
* @param {Object|boolean} [opts] - Options. If `boolean` (deprecated), whether or not to delay execution of root suite until ready.
* @param {boolean} [opts.delay] - Whether to delay execution of root suite until ready.
* @param {boolean} [opts.cleanReferencesAfterRun] - Whether to clean references to test fns and hooks when a suite is done.
*/
Expand All @@ -148,7 +148,10 @@ class Runner extends EventEmitter {
opts = {};
}
if (typeof opts === 'boolean') {
// TODO: deprecate this
// 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 {
Expand Down
10 changes: 10 additions & 0 deletions test/unit/runner.spec.js
Expand Up @@ -11,6 +11,7 @@ const {
MULTIPLE_DONE,
UNSUPPORTED
} = require('../../lib/errors').constants;
const errors = require('../../lib/errors');

const {
EVENT_HOOK_BEGIN,
Expand All @@ -32,6 +33,15 @@ 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;
Expand Down

0 comments on commit 9872410

Please sign in to comment.