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

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
1999 authored and boneskull committed Sep 22, 2016
1 parent 5182a99 commit 7f2c4ae
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 @@ -420,6 +420,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.spec.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.fixture.js', [], function(err, res) {
Expand Down

0 comments on commit 7f2c4ae

Please sign in to comment.