☕️ Classic, reliable, trusted test framework for Node.js and the browser
Deprecate "Runner(suite: Suite, delay: boolean)" (#4646)
Juerg B9872410a717a
diff --git a/lib/runner.js b/lib/runner.jsindex 9ff34171..f493004a 100644--- a/lib/runner.js+++ b/lib/runner.js@@ -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.*/@@ -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 {diff --git a/test/unit/runner.spec.js b/test/unit/runner.spec.jsindex 8f4c6141..80542c78 100644--- a/test/unit/runner.spec.js+++ b/test/unit/runner.spec.js@@ -11,6 +11,7 @@ const {MULTIPLE_DONE,UNSUPPORTED} = require('../../lib/errors').constants;+const errors = require('../../lib/errors');const {EVENT_HOOK_BEGIN,@@ -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;