Skip to content

Commit

Permalink
refactor!: remove deprecated Runner signature (#4861)
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba authored Apr 1, 2022
1 parent 0608fa3 commit b7b849b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
22 changes: 5 additions & 17 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
}
Expand All @@ -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);
Expand Down
10 changes: 0 additions & 10 deletions test/unit/runner.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit b7b849b

Please sign in to comment.