diff --git a/lib/runner.js b/lib/runner.js index 22907f570f..145d990351 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -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; } diff --git a/test/integration/fixtures/regression/issue-2315.js b/test/integration/fixtures/regression/issue-2315.js new file mode 100644 index 0000000000..d3d1f9363c --- /dev/null +++ b/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 () {}); +}); diff --git a/test/integration/regression.spec.js b/test/integration/regression.spec.js index f9f96d31d6..f2a435a34c 100644 --- a/test/integration/regression.spec.js +++ b/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; @@ -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) {