Skip to content

Commit

Permalink
fix: fix uncaught TypeError if error occurs on next tick, closes moch…
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Sorin committed Aug 14, 2016
1 parent 2a51080 commit d5fe815
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/runner.js
Expand Up @@ -414,6 +414,9 @@ Runner.prototype.runTest = function(fn) {
var self = this;
var test = this.test;

if (!test) {
return;
}
if (this.asyncOnly) {
test.asyncOnly = true;
}
Expand Down
7 changes: 7 additions & 0 deletions test/integration/fixtures/regression/issue-2315.js
@@ -0,0 +1,7 @@
describe('issue-2315: cannot read property currentRetry of undefined', function () {
before(function () {
require('http').createServer().listen(1);
});

it('something', function () {});
});
13 changes: 12 additions & 1 deletion test/integration/regression.js
@@ -1,4 +1,4 @@
var assert = require('assert');
var assert = require('assert');
var fs = require('fs');
var path = require('path');
var run = require('./helpers').runMocha;
Expand Down Expand Up @@ -62,6 +62,17 @@ describe('regressions', function() {
});
});

it('issue-2315: cannot read property currentRetry of undefined', function (done) {
runJSON('regression/issue-2315.js', [], function(err, res) {
assert(!err);
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 0);
assert.equal(res.stats.failures, 1);
assert.equal(res.code, 1);
done();
});
});

it('issue-2406: should run nested describe.only suites', function(done) {
this.timeout(2000);
runJSON('regression/issue-2406.js', [], function(err, res) {
Expand Down

0 comments on commit d5fe815

Please sign in to comment.