Angular-cli: SourceMap missing when running ng test with code coverage

Created on 22 Mar 2017  路  5Comments  路  Source: angular/angular-cli

  • [x] bug report

Versions.

@angular/cli: 1.0.0-rc.1
node: 6.9.5
npm: 3.10.1
OS: Windows (7/8/10)

When testing with angular cli, I have found that sourcemapping on all sourcefiles are missing, when using code coverage.

To reproduce:

  1. Generate a new project with the cli.
  2. Run ng test.
  3. Go to the "Debug" page and inspect.
  4. Look up app.component.ts
    Everything sourcemapping should work.

Now repeat those steps , but instead of running ng test use ng test --code-coverage
This time the sourecemapping is missing.

I have made a demo project in which you can use npm run test and npm run test-code-coverage to reproduce the issue.

A possible solution is mentioned in this answer (however only if you have a webpack config)
suggesting this solution

var webpack = require('webpack');
// in your config.set:
plugins: [
  // existing plugins go here
  new webpack.SourceMapDevToolPlugin({
    filename: null, // if no value is provided the sourcemap is inlined
    test: /\.(ts|js)($|\?)/i // process .js and .ts files only
  })
]
devkibuild-angular low investigation inconvenient bufix

Most helpful comment

Agreed, this rarely an issue. It's more like an minor annoyance, but i thought it was worth mentioning.

All 5 comments

We actually do that already: https://github.com/angular/angular-cli/blob/master/packages/@angular/cli/models/webpack-configs/test.ts#L58-L61

It sounds like a bug though. I suppose it has to do with the instrumenting.

This is very low prio though... I mean, what's the usecase? I agree that the sourcemaps should work anyway, but it sounds unlikely for a users to be debugging with code coverage on.

Agreed, this rarely an issue. It's more like an minor annoyance, but i thought it was worth mentioning.

I've been creating unit tests for legacy code that is being upgrade and find that running coverage while writing tests is very helpful to confirm that I am hitting all of the branches. Having source maps working is also a definite help since the code is all in TypeScript.

That said, source maps are working just fine for me when doing unit tests with code coverage turned on.

Angular-cli v6.0.0
Using:
ng new library
ng test _libraryName_ --code-coverage

Prerelease version of version 1.0.0 are no longer supported. Please open a new issue if the problem persists on a stable version.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gotschmarcel picture gotschmarcel  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments

jmurphzyo picture jmurphzyo  路  3Comments

daBishMan picture daBishMan  路  3Comments

hartjo picture hartjo  路  3Comments