diff --git a/lib/runner.js b/lib/runner.js index d105bca321..dc2092f9fa 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -851,10 +851,15 @@ Runner.prototype.run = function(fn) { filterOnly(rootSuite); } self.started = true; - self.emit('start'); + Runner.immediately(function() { + self.emit('start'); + }); + self.runSuite(rootSuite, function() { debug('finished running'); - self.emit('end'); + Runner.immediately(function() { + self.emit('end'); + }); }); } diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.js index 3f7145834c..7c91add7f3 100644 --- a/test/unit/mocha.spec.js +++ b/test/unit/mocha.spec.js @@ -34,6 +34,16 @@ describe('Mocha', function() { }); } ); + + it('should emit start event', function(done) { + var mocha = new Mocha(blankOpts); + mocha.run().on('start', done); + }); + + it('should emit end event', function(done) { + var mocha = new Mocha(blankOpts); + mocha.run().on('end', done); + }); }); describe('.addFile()', function() {