Skip to content

Commit e1389ef

Browse files
authored
Fix: runner listening to 'start' and 'end' events (#3660)
1 parent 9cbb6f6 commit e1389ef

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/runner.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,9 @@ Runner.prototype.run = function(fn) {
939939
this.emit(constants.EVENT_DELAY_BEGIN, rootSuite);
940940
rootSuite.once(EVENT_ROOT_SUITE_RUN, start);
941941
} else {
942-
start();
942+
Runner.immediately(function() {
943+
start();
944+
});
943945
}
944946

945947
return this;

test/unit/mocha.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,16 @@ describe('Mocha', function() {
487487
}, 'not to throw');
488488
});
489489

490+
it('should catch the `start` event if no tests are provided', function(done) {
491+
var mocha = new Mocha(opts);
492+
mocha.run().on('start', done);
493+
});
494+
495+
it('should catch the `end` event if no tests are provided', function(done) {
496+
var mocha = new Mocha(opts);
497+
mocha.run().on('end', done);
498+
});
499+
490500
describe('#reporter("xunit")#run(fn)', function() {
491501
// :TBD: Why does specifying reporter differentiate this test from preceding one
492502
it('should not raise errors if callback was not provided', function() {

0 commit comments

Comments
 (0)