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

Fix: potential call-stack crash when using 'dry-run' option #4839

Merged
merged 2 commits into from Mar 4, 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
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();
});
});
});