diff --git a/lib/runner.js b/lib/runner.js index 17fa290432..8e7c8736c0 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -939,7 +939,9 @@ Runner.prototype.run = function(fn) { this.emit(constants.EVENT_DELAY_BEGIN, rootSuite); rootSuite.once(EVENT_ROOT_SUITE_RUN, start); } else { - start(); + Runner.immediately(function() { + start(); + }); } return this; diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.js index 33cd0fdb8e..bc460aa845 100644 --- a/test/unit/mocha.spec.js +++ b/test/unit/mocha.spec.js @@ -487,6 +487,16 @@ describe('Mocha', function() { }, 'not to throw'); }); + it('should catch the `start` event if no tests are provided', function(done) { + var mocha = new Mocha(opts); + mocha.run().on('start', done); + }); + + it('should catch the `end` event if no tests are provided', function(done) { + var mocha = new Mocha(opts); + mocha.run().on('end', done); + }); + describe('#reporter("xunit")#run(fn)', function() { // :TBD: Why does specifying reporter differentiate this test from preceding one it('should not raise errors if callback was not provided', function() {