diff --git a/lib/reporter.js b/lib/reporter.js index fd53e8d..f174398 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -120,7 +120,17 @@ const AggregatedCoverageReporter = function(injector, logger, config, baseReport }; this.onExit = function(done) { - callThrough('onExit', done); + // We cannot call callThrough here as we must determine when all relevant reporters have called done() + const promises = reporters.map(({name, reporter}) => new Promise((resolve) => { + if (_.isFunction(reporter.onExit)) { + log.debug(`relaying done() on reporter:${name}`); + reporter.onExit(() => resolve()); + } else { + resolve(); + } + })); + + Promise.all(promises).then(() => done()); }; };