refactor(@angular-devkit/build-angular): mute internal reporters (#11238)

* refactor(@angular-devkit/build-angular): mute internal reporters when
other reporters are configured

internal Karma reporters should suppress output when user-defined
reporters are configured to prevent extrananeous error reporting for
failed tests

* refactor(@angular-devkit/build-angular): mute internal reporters when
other reporters are configured

internal Karma reporters should suppress output when user-defined
reporters are configured to prevent extrananeous error reporting for
failed tests
This commit is contained in:
Corinna Cohn 2018-08-14 10:29:40 -04:00 committed by Alex Eagle
parent ffdbb0a1cf
commit f46869d4ed

View File

@ -229,10 +229,29 @@ function requestBlocker() {
};
}
// 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.
function muteDuplicateReporterLogging(context: any, config: any) {
context.writeCommonMsg = function () { };
const reporterName = '@angular/cli';
const hasTrailingReporters = config.reporters.slice(-1).pop() !== reporterName;
if (hasTrailingReporters) {
context.writeCommonMsg = function () { };
}
}
// Emits builder events.
const eventReporter: any = function (this: any, baseReporterDecorator: any) {
const eventReporter: any = function (this: any, baseReporterDecorator: any, config: any) {
baseReporterDecorator(this);
muteDuplicateReporterLogging(this, config);
this.onRunComplete = function (_browsers: any, results: any) {
if (results.exitCode === 0) {
successCb && successCb();
@ -245,25 +264,13 @@ const eventReporter: any = function (this: any, baseReporterDecorator: any) {
this.specFailure = () => {};
};
eventReporter.$inject = ['baseReporterDecorator'];
eventReporter.$inject = ['baseReporterDecorator', 'config'];
// Strip the server address and webpack scheme (webpack://) from error log.
const sourceMapReporter: 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 () { };
}
muteDuplicateReporterLogging(this, config);
const urlRegexp = /\(http:\/\/localhost:\d+\/_karma_webpack_\/webpack:\//gi;