Skip to content

Commit

Permalink
fix(dry-run): potential call-stack crash with 'dry-run' option (#4839)
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Mar 4, 2022
1 parent 547ffd7 commit 22f9306
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/runner.js
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions 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);
});
});
}
});
12 changes: 12 additions & 0 deletions test/integration/options/dryRun.spec.js
Expand Up @@ -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();
});
});
});

0 comments on commit 22f9306

Please sign in to comment.