-
Notifications
You must be signed in to change notification settings - Fork 12k
ng test --code-coverage in 6.1 improperly detecting branches #11672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Not providing any solution here, but the problem is likely to be in Devkit 0.7 instead of CLI 6.1. |
same issue after upgrade to 6.1.1. coverage dropped from 100% |
Had the same problem after upgrading to cli 6.1.1 + devkit 0.7.1. Fixed by downgrading Before (with coverage issues):
After (coverage working properly again):
|
I'm guessing something is wrong in the creation or handling source maps? |
Hope this gets fixed soon need to be on latest version of the @angular-devkit/build-angular because of the issue in 0.6.8 of it not exiting with proper error code but now this coverage report issue is a problem. |
Maybe it's the way that the sourceMaps are handled. If I add "sourceMap": true, in the test section, with @angular-devkit/build-angular 0.7.0 it seems to work. |
I'm on 0.7.1, and adding |
Maybe you have a tsconfig.json with "sourceMap": false ? Here my DevDependecies:
|
I can confirm that setting |
Hmm, updated to 0.7.2, but still no luck. tsconfig.spec.json doesn't set
None of these tweaks make any difference. The coverage report is generated but the highlighting is all wrong. |
See angular cli regression: angular/angular-cli#11672
See angular cli regression: angular/angular-cli#11672
See angular cli regression: angular/angular-cli#11672
I have tried various versions and combinations of "sourceMap" set to true/false with no luck. My particular use case is a library that will later be imported by another app, so downgrading anything is proving problematic, as the "library" generation in Angular CLI 6 is fresh and shiny and new. |
Same issue as @frankrue - setting sourcemap to true did not resolve the issue. EDIT: A bit more clarification - it does not work for libraries generated with Angular CLI 6. |
fixed by adding "sourceMap": true |
Adding sourceMap: true does appear to fix the code coverage problem for me, but it seems to make failure stack traces disappear: Without sourceMap: true:
With sourceMap: true:
|
I was able to fix the issue by adding DevDependency versions are,
|
In my case passing the |
@hansl will this be making it into the ng7 release? |
I can confirm this issue. And I can confirm that running it using Here's my
|
Also confirm running ng test --code-coverage --source-map solves this, despite all settings being set to sourceMap:true. Of course, this advice conflicts with the advice given in #11968. 😞 |
Unfortunately, I'm on the latest versions and I'm still getting the wonky coverage highlighting in the coverage report. Even using Angular CLI: 6.2.1 Package Version@angular-devkit/architect 0.8.1 And in case the versions related to Karma matter: |
Using --sourceMap=true does not solve the problem for me as it actually causes the test to hang. I.e. when I specify --sourceMap=true it goes to a blank screen and remains there indefinitely. |
Could we get an update from someone on the Angular team on this? It's been open for 5 weeks as a priority 1 bug, but there hasn't been any comment from the team yet. |
we're planning a bug bash sprint starting in 1.5 weeks; as a P1 this issue will be on it. |
FYI, I made the local change that was done in https://github.com/angular/angular-cli/pull/12291/files, but the coverage report highlighting is still messed up. Not sure if that's expected for now (I'm on @angular-devkit/build-angular 0.8.1, and don't know if other things have changed beyond that one schema change), but figured I'd mention it. |
For anyone here from Google, I may have found a more permanent fix than using the CLI flag. Set "sourceMap": true in angular.json under projects -> [yourProject] -> architect -> test -> options. Making the change in the tsconfig.spec.json or tsconfig.json had no effect for me. My environment:
|
The code coverage generated by ng test was erroneous, as per angular/angular-cli#11672 I'm passing in --source-map as a workaround until this is fixed in Angular cli.
Just had the same problem start happening to me,
@lanegoolsby 's solution worked out for me, didn't have to add anything into the CLI commands, just the |
Thought it might be worth noting that I'm still seeing this issue... After adding |
Is there any update on this? I have also set the sourceMaps property to true and believe I am now seeing more "believable" code coverage metrics. However, the highlighting in the reporting is horribly horribly wrong. How can I have any confidence over the quoted coverage metrics? |
This is fixed in ng7 |
I am still having the same issue with all dependencies completely up to date |
Does this means it is not fixed for ng6 |
This is still broken, running these dependencies
With |
FYI, I'm on the latest versions (Angular 8) and I'm still getting a non-accurate coverage report. Even using Here is my configuration: package.json
Angular.CLI
angular.json
If some more informations are needed dont hasitate to write me. I am very interested to help solving this problem. Thanks in advance |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report or Feature Request (mark with an
x
)Command (mark with an
x
)Versions
OS: macOS Sierra
Node: v8.9.4
NPM: 6.2.0
Ng Version:
Repro steps
Run

ng test --code-coverage
Notice that things like import statements are counted as if else branches.
The log given by the failure
No log file
Desired functionality
I expect to see things like import statements and decorator metadata to not be marked as if else branches in the code coverage report.
Mention any other details that might be useful
The text was updated successfully, but these errors were encountered: