Javascript has following code coverage options like: Istanbul, Karma, Blanket.js, and JSCover.But what about these tools support in Angular2 ? We know Istanbul is possible with Angular2 ,but what about other coverage tools.
Asked
Active
Viewed 1,183 times
-2
-
I refereed this question and answer is clear from that http://stackoverflow.com/questions/36108640/webpack-karma-istanbul-remapping-for-typescript. – S Vasudev Apr 17 '17 at 12:43
2 Answers
1
The Angular CLI creates projects with Istanbul built-in. You run ng test --code-coverage
to get the lcov
file generated, and you get access to the karma config in your project to customize the integration as needed.
For example, in my project, in the file karma.conf.js
, I have things like:
coverageIstanbulReporter: { dir: '../reports/jsCoverage', reports: [ 'html', 'lcovonly' ], fixWebpackSourcePaths: true }, ... reporters: config.angularCli && config.angularCli.codeCoverage ? ['progress', 'coverage-istanbul'] : ['progress', 'kjhtml'],
Update:
In the recent versions of Angular CLI (not sure since when, but sure in v 1.2+, maybe even 1.1), your karma config doesn't even have the reporter
part above. The CLI adds coverage-istanbul
by itself as needed.

Meligy
- 35,654
- 11
- 85
- 109
-
1The correct command in the current version is ng test --code-coverage, not ng test --coverage – RMorrisey Sep 05 '17 at 14:25
0
This link clearly explains typescript based Code coverage :-https://www.sitepen.com/blog/2015/09/29/code-coverage-for-typescript-and-other-transpiled-languages/

S Vasudev
- 23
- 10