☕️ Classic, reliable, trusted test framework for Node.js and the browser
fix(dry-run): potential call-stack crash with 'dry-run' option (#4839)
Juerg B22f930626528
diff --git a/lib/runner.js b/lib/runner.jsindex 787f29e6..23a43c6f 100644--- a/lib/runner.js+++ b/lib/runner.js@@ -655,7 +655,7 @@ Runner.prototype.parents = function () {* @private*/Runner.prototype.runTest = function (fn) {- if (this._opts.dryRun) return fn();+ if (this._opts.dryRun) return Runner.immediately(fn);var self = this;var test = this.test;diff --git a/test/integration/fixtures/options/dry-run/stack-size.fixture.js b/test/integration/fixtures/options/dry-run/stack-size.fixture.jsnew file mode 100644index 00000000..8b5960e6--- /dev/null+++ b/test/integration/fixtures/options/dry-run/stack-size.fixture.js@@ -0,0 +1,11 @@+var assert = require('assert');++describe('Wrapper suite', function () {+ for(let i=0; i < 400; i++) {+ describe(`suite ${i}`, function () {+ it(`test ${i}`, function () {+ assert.equal(1, 1);+ });+ });+ }+});diff --git a/test/integration/options/dryRun.spec.js b/test/integration/options/dryRun.spec.jsindex ec7b6f92..45eeabee 100644--- a/test/integration/options/dryRun.spec.js+++ b/test/integration/options/dryRun.spec.js@@ -27,4 +27,16 @@ describe('--dry-run', function () {done();});});++ it('should pass without "RangeError: maximum call stack size exceeded"', function (done) {+ var fixture = path.join('options/dry-run', 'stack-size');+ runMochaJSON(fixture, args, function (err, res) {+ if (err) {+ return done(err);+ }++ expect(res, 'to have passed test count', 400);+ done();+ });+ });});