Skip to content

Commit 00ca06b

Browse files
outsiderisplroebuck
authored andcommitted
fix runner to emit start/end event (#3395)
Signed-off-by: Outsider <[email protected]>
1 parent 3e77008 commit 00ca06b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/runner.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -851,10 +851,15 @@ Runner.prototype.run = function(fn) {
851851
filterOnly(rootSuite);
852852
}
853853
self.started = true;
854-
self.emit('start');
854+
Runner.immediately(function() {
855+
self.emit('start');
856+
});
857+
855858
self.runSuite(rootSuite, function() {
856859
debug('finished running');
857-
self.emit('end');
860+
Runner.immediately(function() {
861+
self.emit('end');
862+
});
858863
});
859864
}
860865

test/unit/mocha.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ describe('Mocha', function() {
3434
});
3535
}
3636
);
37+
38+
it('should emit start event', function(done) {
39+
var mocha = new Mocha(blankOpts);
40+
mocha.run().on('start', done);
41+
});
42+
43+
it('should emit end event', function(done) {
44+
var mocha = new Mocha(blankOpts);
45+
mocha.run().on('end', done);
46+
});
3747
});
3848

3949
describe('.addFile()', function() {

0 commit comments

Comments
 (0)