{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular-cli/issues/11227","repository_url":"https://api.github.com/repos/angular/angular-cli","labels_url":"https://api.github.com/repos/angular/angular-cli/issues/11227/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular-cli/issues/11227/comments","events_url":"https://api.github.com/repos/angular/angular-cli/issues/11227/events","html_url":"https://github.com/angular/angular-cli/issues/11227","id":331962943,"node_id":"MDU6SXNzdWUzMzE5NjI5NDM=","number":11227,"title":"ng test --code-coverage gives wrong results and do not include all files","user":{"login":"zielinskikamil","id":12416106,"node_id":"MDQ6VXNlcjEyNDE2MTA2","avatar_url":"https://avatars0.githubusercontent.com/u/12416106?v=4","gravatar_id":"","url":"https://api.github.com/users/zielinskikamil","html_url":"https://github.com/zielinskikamil","followers_url":"https://api.github.com/users/zielinskikamil/followers","following_url":"https://api.github.com/users/zielinskikamil/following{/other_user}","gists_url":"https://api.github.com/users/zielinskikamil/gists{/gist_id}","starred_url":"https://api.github.com/users/zielinskikamil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zielinskikamil/subscriptions","organizations_url":"https://api.github.com/users/zielinskikamil/orgs","repos_url":"https://api.github.com/users/zielinskikamil/repos","events_url":"https://api.github.com/users/zielinskikamil/events{/privacy}","received_events_url":"https://api.github.com/users/zielinskikamil/received_events","type":"User","site_admin":false},"labels":[{"id":957896443,"node_id":"MDU6TGFiZWw5NTc4OTY0NDM=","url":"https://api.github.com/repos/angular/angular-cli/labels/comp:%20devkit/build-angular","name":"comp: devkit/build-angular","color":"c5def5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-13T11:58:00Z","updated_at":"2018-07-31T00:12:13Z","closed_at":null,"author_association":"NONE","body":"### Bug Report or Feature Request (mark with an `x`)\r\n```\r\n- [x] bug report\r\n- [ ] feature request\r\n```\r\n\r\n### Area\r\n```\r\n- [x] devkit\r\n- [ ] schematics\r\n```\r\n\r\n### Versions\r\nnode v8.9.4\r\nnpm 5.6.0\r\nmacOS Sierra\r\n\r\n### Repro steps\r\n```\r\nng new CoverageTest\r\ncd CoverageTest\r\nng g component componentA\r\nng g component componentB\r\n// add dumy public method to componentb.ts\r\n/*\r\n Additionally create some file and put there some simple class with one method. eg.\r\nclass ServiceA {\r\n    public getHello(): string {\r\n        return 'hello';\r\n    }\r\n}\r\n*/\r\n\r\n// now generate code coverage\r\nng test --code-coverage --watch false\r\n// open coverage/index.html\r\n```\r\n\r\n### Description\r\nCode coverage generates a report but its misleading:\r\n1. It doesn't include `ServiceA` coverage\r\n2. Despite there are just two methods in `componentb`, coverage is eqal to 80%. If I preview covered area it covered untested file as well!\r\n3. After editing `test.ts` (replace  \r\n`const context = require.context('./', true, /\\.spec\\.ts$/);`\r\nwith\r\n`const context = require.context('./', true, /\\/app\\/.*\\.ts$/);`\r\nand reruning `ng test --code-coverage --watch false`\r\nServiceA is visible in report but has some unrealistic values (Statement Coverage at 80%, Branches at 100%, Lines 83%)\r\n\r\n\r\n### Desired functionality\r\nAd 1. Coverage that does not include all files is misleading. How do I know which files are covered in unit tests?\r\nAd 2. How it happened that componentB is covered in 80% and newly created method is not covered in view? I suspect that mechanism that loads JS makes such faults positive scenario.\r\nAd 3. Why ServiceA shows as being covered despite there were no test for it?\r\n\r\nAll these 3 things look like a bug. Can you guys take a look at it?\r\n"},"comment":{"url":"https://api.github.com/repos/angular/angular-cli/issues/comments/409052121","html_url":"https://github.com/angular/angular-cli/issues/11227#issuecomment-409052121","issue_url":"https://api.github.com/repos/angular/angular-cli/issues/11227","id":409052121,"node_id":"MDEyOklzc3VlQ29tbWVudDQwOTA1MjEyMQ==","user":{"login":"sumeet-singh04","id":6270649,"node_id":"MDQ6VXNlcjYyNzA2NDk=","avatar_url":"https://avatars1.githubusercontent.com/u/6270649?v=4","gravatar_id":"","url":"https://api.github.com/users/sumeet-singh04","html_url":"https://github.com/sumeet-singh04","followers_url":"https://api.github.com/users/sumeet-singh04/followers","following_url":"https://api.github.com/users/sumeet-singh04/following{/other_user}","gists_url":"https://api.github.com/users/sumeet-singh04/gists{/gist_id}","starred_url":"https://api.github.com/users/sumeet-singh04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumeet-singh04/subscriptions","organizations_url":"https://api.github.com/users/sumeet-singh04/orgs","repos_url":"https://api.github.com/users/sumeet-singh04/repos","events_url":"https://api.github.com/users/sumeet-singh04/events{/privacy}","received_events_url":"https://api.github.com/users/sumeet-singh04/received_events","type":"User","site_admin":false},"created_at":"2018-07-31T00:12:13Z","updated_at":"2018-07-31T00:12:13Z","author_association":"NONE","body":"Any updates on this issue ? I am able to exclude files using the angular.json, but not sure how to add them."}}
{"actor":{"display_login":"sumeet-singh04"}}