Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit 7f2c4ae

Browse files
1999boneskull
authored andcommitted
fix: fix uncaught TypeError if error occurs on next tick, closes mochajs#2315 (mochajs#2439)
1 parent 5182a99 commit 7f2c4ae

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

lib/runner.js

+3
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,9 @@ Runner.prototype.runTest = function(fn) {
420420
var self = this;
421421
var test = this.test;
422422

423+
if (!test) {
424+
return;
425+
}
423426
if (this.asyncOnly) {
424427
test.asyncOnly = true;
425428
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
describe('issue-2315: cannot read property currentRetry of undefined', function () {
2+
before(function () {
3+
require('http').createServer().listen(1);
4+
});
5+
6+
it('something', function () {});
7+
});

test/integration/regression.spec.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var assert = require('assert');
1+
var assert = require('assert');
22
var fs = require('fs');
33
var path = require('path');
44
var run = require('./helpers').runMocha;
@@ -62,6 +62,17 @@ describe('regressions', function() {
6262
});
6363
});
6464

65+
it('issue-2315: cannot read property currentRetry of undefined', function (done) {
66+
runJSON('regression/issue-2315.js', [], function(err, res) {
67+
assert(!err);
68+
assert.equal(res.stats.pending, 0);
69+
assert.equal(res.stats.passes, 0);
70+
assert.equal(res.stats.failures, 1);
71+
assert.equal(res.code, 1);
72+
done();
73+
});
74+
});
75+
6576
it('issue-2406: should run nested describe.only suites', function(done) {
6677
this.timeout(2000);
6778
runJSON('regression/issue-2406.fixture.js', [], function(err, res) {

0 commit comments

Comments
 (0)