karma-coverage icon indicating copy to clipboard operation
karma-coverage copied to clipboard

karma-coverage must be installed in order to run code coverage

Open sysmat opened this issue 3 years ago • 3 comments

"karma": "^5.2.3",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "^2.0.3",
    "karma-jasmine": "~4.0.1",
    "karma-jasmine-html-reporter": "^1.5.4",
    "karma-spec-reporter": "0.0.32",

and installed

sysmat avatar Nov 12 '20 13:11 sysmat

I had the same issue after updating my project to Angular 11, and trying to set up karma-coverage.

Fixed it by adding the kjhtml reporter instead of the coverage reporter:

reporters: ['progress', 'kjhtml'],

Next time when you open such an issue, please give more context. With the little information you provided it is nearly impossible to help you.

dkimmich-onventis avatar Nov 12 '20 15:11 dkimmich-onventis

The same problem with angular 11

sysmat avatar Nov 12 '20 15:11 sysmat

Make sure you have it in plugins section: karma.conf.js

    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage'),  <--- add this line
      require('@angular-devkit/build-angular/plugins/karma'),
    ],

The official doc assumes that you know what you're doing and omits plugins section in the example I think. https://github.com/karma-runner/karma-coverage#basic image

johnsonlin avatar Dec 02 '20 07:12 johnsonlin