Skip to content

ng test --code-coverage produces corrupted coverage reports #12343

Closed
@corcorb

Description

@corcorb

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [x] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

$ node --version
v10.3.0
$ npm --version
6.4.1
$ ng --version
...
Angular CLI: 6.2.3
Node: 10.3.0
OS: darwin x64
Angular: 6.1.8
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.8.3
@angular-devkit/build-angular     0.8.3
@angular-devkit/build-optimizer   0.8.3
@angular-devkit/build-webpack     0.8.3
@angular-devkit/core              0.8.3
@angular-devkit/schematics        0.8.3
@angular/cli                      6.2.3
@ngtools/webpack                  6.2.3
@schematics/angular               0.8.3
@schematics/update                0.8.3
rxjs                              6.2.2
typescript                        2.9.2
webpack                           4.19.1

macOS High Sierra (10.13.6)

Repro steps

Create a brand new project, run tests with code coverage:

ng new stock-ng-project
cd stock-ng-project
ng test --watch=false --code-coverage

Open the generated istanbul report:

open coverage/src/app/app.component.ts.html

The log given by the failure

No explicit error.

The report is malformed, including:

  • highlights that don't correspond to tokens
  • Random characters (I, E)
  • Gutter markers that don't correspond to lines with code

Desired functionality

It should be like the version from @angular-devkit/build-angular 0.6.8:

npm install --only=dev @angular-devkit/build-angular@0.6.8
ng test --watch=false --code-coverage
open coverage/src/app/app.component.ts.html

The report is correctly formatted.

Mention any other details that might be useful

I've tracked this to being introduced by the upgrade of @angular-devkit/build-angular from 0.6.8 to 0.7.0, but that added/updated a lot of webpack and source-map-loader dependencies, and I'm not sure what the root cause is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions