Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

fix runner to emit start/end event (#3395)

JeongHoon Byun (aka Outsider)00ca06b0e957
diff --git a/lib/runner.js b/lib/runner.js
index d105bca3..dc2092f9 100644
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -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');
+ });
});
}
diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.js
index 3f714583..7c91add7 100644
--- a/test/unit/mocha.spec.js
+++ b/test/unit/mocha.spec.js
@@ -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() {