Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated Runner signature #4861

Merged
merged 1 commit into from Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 5 additions & 17 deletions lib/runner.js
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
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