diff --git a/packages/@angular/cli/plugins/karma.ts b/packages/@angular/cli/plugins/karma.ts index 5995e9b38ad0..c2e992755256 100644 --- a/packages/@angular/cli/plugins/karma.ts +++ b/packages/@angular/cli/plugins/karma.ts @@ -247,8 +247,23 @@ function requestBlocker() { } // Strip the server address and webpack scheme (webpack://) from error log. -const initSourcemapReporter: any = function (this: any, baseReporterDecorator: any) { +const initSourcemapReporter: any = function (this: any, baseReporterDecorator: any, config: any) { baseReporterDecorator(this); + + const reporterName = '@angular/cli'; + const hasTrailingReporters = config.reporters.slice(-1).pop() !== reporterName; + + // Copied from "karma-jasmine-diff-reporter" source code: + // In case, when multiple reporters are used in conjunction + // with initSourcemapReporter, they both will show repetitive log + // messages when displaying everything that supposed to write to terminal. + // So just suppress any logs from initSourcemapReporter by doing nothing on + // browser log, because it is an utility reporter, + // unless it's alone in the "reporters" option and base reporter is used. + if (hasTrailingReporters) { + this.writeCommonMsg = function () {}; + } + const urlRegexp = /\(http:\/\/localhost:\d+\/_karma_webpack_\/webpack:\//gi; this.onSpecComplete = function (_browser: any, result: any) { @@ -260,7 +275,7 @@ const initSourcemapReporter: any = function (this: any, baseReporterDecorator: a }; }; -initSourcemapReporter.$inject = ['baseReporterDecorator']; +initSourcemapReporter.$inject = ['baseReporterDecorator', 'config']; module.exports = Object.assign({ 'framework:@angular/cli': ['factory', init],