Skip to content

armgit / mocha

Public Imported from GitHub
0

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

if a reporter has a .done method, call it before exiting

Michael Demmer30582e646d57
diff --git a/lib/mocha.js b/lib/mocha.js
index a224112b..730229c3 100644
--- a/lib/mocha.js
+++ b/lib/mocha.js
@@ -367,5 +367,14 @@ Mocha.prototype.run = function(fn){
if (options.growl) this._growl(runner, reporter);
exports.reporters.Base.useColors = options.useColors;
exports.reporters.Base.inlineDiffs = options.useInlineDiffs;
- return runner.run(fn);
+
+ function done(failures) {
+ if (reporter.done) {
+ reporter.done(failures, fn);
+ } else {
+ fn(failures);
+ }
+ }
+
+ return runner.run(done);
};