From 30582e646d579ce67ef4229922651da498e79a80 Mon Sep 17 00:00:00 2001 From: Michael Demmer Date: Sat, 17 May 2014 14:52:46 -0700 Subject: [PATCH] if a reporter has a .done method, call it before exiting --- lib/mocha.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/mocha.js b/lib/mocha.js index a224112b4d..730229c3b7 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); };