Skip to content

Commit

Permalink
fix runner to emit start/end event (#3395)
Browse files Browse the repository at this point in the history
Signed-off-by: Outsider <[email protected]>
  • Loading branch information
outsideris authored and plroebuck committed Nov 2, 2018
1 parent 3e77008 commit 00ca06b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
}

Expand Down
10 changes: 10 additions & 0 deletions test/unit/mocha.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 00ca06b

Please sign in to comment.