Skip to content

Commit 22f9306

Browse files
authored
fix(dry-run): potential call-stack crash with 'dry-run' option (#4839)
1 parent 547ffd7 commit 22f9306

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

lib/runner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ Runner.prototype.parents = function () {
655655
* @private
656656
*/
657657
Runner.prototype.runTest = function (fn) {
658-
if (this._opts.dryRun) return fn();
658+
if (this._opts.dryRun) return Runner.immediately(fn);
659659

660660
var self = this;
661661
var test = this.test;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var assert = require('assert');
2+
3+
describe('Wrapper suite', function () {
4+
for(let i=0; i < 400; i++) {
5+
describe(`suite ${i}`, function () {
6+
it(`test ${i}`, function () {
7+
assert.equal(1, 1);
8+
});
9+
});
10+
}
11+
});

test/integration/options/dryRun.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,16 @@ describe('--dry-run', function () {
2727
done();
2828
});
2929
});
30+
31+
it('should pass without "RangeError: maximum call stack size exceeded"', function (done) {
32+
var fixture = path.join('options/dry-run', 'stack-size');
33+
runMochaJSON(fixture, args, function (err, res) {
34+
if (err) {
35+
return done(err);
36+
}
37+
38+
expect(res, 'to have passed test count', 400);
39+
done();
40+
});
41+
});
3042
});

0 commit comments

Comments
 (0)