@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:
ng test. app.component.tsNow 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
})
]
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._
Most helpful comment
Agreed, this rarely an issue. It's more like an minor annoyance, but i thought it was worth mentioning.