☕️ Classic, reliable, trusted test framework for Node.js and the browser
Fix: runner listening to 'start' and 'end' events (#3660)
Juerg Be1389efd949f
diff --git a/lib/runner.js b/lib/runner.jsindex 17fa2904..8e7c8736 100644--- a/lib/runner.js+++ b/lib/runner.js@@ -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;diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.jsindex 33cd0fdb..bc460aa8 100644--- a/test/unit/mocha.spec.js+++ b/test/unit/mocha.spec.js@@ -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 oneit('should not raise errors if callback was not provided', function() {