Skip to content

Commit

Permalink
Fix: runner listening to 'start' and 'end' events (#3660)
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Mar 9, 2020
1 parent 9cbb6f6 commit e1389ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/runner.js
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions test/unit/mocha.spec.js
Expand Up @@ -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() {
Expand Down

0 comments on commit e1389ef

Please sign in to comment.