nehzzq
Last Updated: February 25, 2016
·
2.172K
· skeep
838e261917d5ad8e5d1f65c336702365

Enable Istanbul in Yeoman angular generator

Istanbul test coverage report is awesome. Good thing is it comes canned with Karma Test runner. If you are using angular generator for yeoman, it do not come pre-configured though. But enabling it is easy.

First you need to enable the reporter in karma.conf.js
Replace the below line

reporters = ['progress'];

with this

reporters = ['progress','coverage'];

//coverage reporter type
coverageReporter = {
    type : 'html'
}

This adds the coverage reporter. But we need tell which files it need to cover.

To do that add the below lines anywhere in your karma.conf.js file

//initiate istanbul code coverage report
preprocessors = {
    'app/scripts/**/*.js': 'coverage'
};

That's it. Every time you run test task, the coverage report should get generated in the root folder.

Say Thanks
Respond

1 Response
Add your response

13595
Screen shot 2011 09 12 at 8.50.54 am  blue

Many thanks for this. One note, you need to be sure, that karma-coverage is installed.
Example output: http://gotwarlost.github.io/istanbul/public/coverage/lcov-report/index.html

over 1 year ago ·