O'Reilly logo

Continuous Integration, Delivery, and Deployment by Sander Rossel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Code coverage

Karma can also give you code coverage reports. Code coverage indicates how much of your code is tested. For example, if you have two functions, each 10 lines long, and you test one, you should have a code coverage of 50%. Code coverage is a little more sophisticated than that, as we will see in a moment.

Before we start, we will need to install the karma-coverage plugin:

npm install karma-coverage --save-dev

After that, we need to change our configuration, so Karma will run the coverage plugin. We will need to indicate the coverage preprocessor, the coverageReporter, and the type of reporter:

preprocessors: { '../scripts/*.js': ['coverage'] }, reporters: ['progress', 'coverage'], coverageReporter: { reporters: [ { type : 'html', ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required