Skip to content

initSourcemapReporter causes double logs to the console #9528

Closed
@shairez

Description

@shairez

Versions

Angular CLI: 1.6.5
Node: 8.9.0
OS: win32 x64
Angular: 5.2.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.6.5
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.5
@schematics/angular: 0.1.17
typescript: 2.5.3
webpack: 3.10.0

Repro steps

  • Install karma-mocha-reporter and add it to the plugins array
  • replace progress with mocha in the reporters array in karma.conf.js
  • Add a console.log('TEST') to one of your tests
  • See it being logged twice

(By the way, it also happens with karma-spec-reporter, so it isn't just a mocha-reporter thing)

Observed behavior

Console logs are being logged twice because the initSourcemapReporter inherits from the base reporter which implements the onBrowserLog function by default, so every log the browser emits is being logged by every reporter that doesn't override the write method.

Desired behavior

I want console.logs from test to be displayed only once when reporting using different reporters

Mention any other details that might be useful (optional)

I'm about to submit a PR which fixes this.
Another possible fix is to change the behavior in Karma, but that's out of this repo's scope.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions