From a17b6ca48053f2b5ff7659f1d5794317187b51d9 Mon Sep 17 00:00:00 2001 From: Matt Lewis Date: Wed, 23 May 2018 10:10:34 +0100 Subject: [PATCH] fix: don't log errors twice when using multiple reporters Fixes #44 --- src/reporter.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/reporter.js b/src/reporter.js index bd825c9..b9c7f7e 100644 --- a/src/reporter.js +++ b/src/reporter.js @@ -19,6 +19,15 @@ function checkThresholds(thresholds, summary) { function CoverageIstanbulReporter(baseReporterDecorator, logger, config) { baseReporterDecorator(this); + // Copied from https://github.com/angular/angular-cli/pull/9529/files + // Fixes https://github.com/mattlewis92/karma-coverage-istanbul-reporter/issues/44 + const reporterName = 'coverage-istanbul'; + const hasTrailingReporters = + config.reporters.slice(-1).pop() !== reporterName; + if (hasTrailingReporters) { + this.writeCommonMsg = () => {}; + } + const log = logger.create('reporter.coverage-istanbul'); const browserCoverage = new WeakMap(); const coverageConfig = Object.assign({}, config.coverageIstanbulReporter);