karma-coverage: "Can not load "coverage", it is not registered!" error when running

I install karma-coverage like this: npm install karma-coverage --save-dev

I have a package file that contains this: “devDependencies”: { “karma”: “0.10.2”, “karma-coverage”: “0.1.5”, “karma-junit-reporter”: “0.1.0”, “karma-jasmine”: “0.1.3”, “karma-chrome-launcher”: “0.1.0”, “karma-ie-launcher”: “0.1.1”, “karma-safari-launcher”: “0.1.1”, “karma-firefox-launcher”: “0.1.0” },

And a config file that looks contains this: // test results reporter to use // possible values: ‘dots’, ‘progress’, ‘junit’, ‘growl’, ‘coverage’ reporters: [‘dots’, ‘junit’, ‘coverage’],

preprocessors: {
  // source files, that you wanna generate coverage for
  // do not include tests or libraries
  // (these files will be instrumented by Istanbul)
  'jstarget/**/*.js': ['coverage']
},

// configure the coverage reporter
coverageReporter: {
  type : 'html',
  dir : 'coverage/'
},

And I get an error that looks like this: WARN [reporter]: Can not load “coverage”, it is not registered! Perhaps you are missing some plugin?

What do I need to do?

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 23 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I forgot to add karma-coverage to the list of plugins. This should be added to the sample config in the readme.

I had this problem as well. I was able to get things working once I deleted all the global karma packages and reinstalled karma-cli as the only global (karma-related) package.

I got the same [WARN] because the plugin ‘karma-coverage’ was not defined inside the plugins of the config, try to see if adding it fixes your warning, not sure if it will fix your full problem.

plugins: [
  'karma-jasmine',
  'karma-coverage'
],

I had this problem on the build server (team city) and it turned out to be because I’d installed karma globally, instead of karma-cli (which is the only one needed globally on the build server)

I have no plugins defined in config, they are loaded automatically via their naming convention.

Solution found here

@apond what is your set up look like?

The recommended way is to install karma and all the plugins in your project (not global). Then, Karma automatically loads all the plugins (karma-*).

I had the same problem and just fix it after added ‘karma-coverage’ package, and then, in the karma.conf.js file, remove the require of karma-coverage-istanbul-reporter, and finally add the require of the new package, like this: require(‘karma-coverage’)

I hope this will be helpfull.

I’ve found that if I declare the plugins option with any values, it fails to load all the karma-* modules. if I remove it altogether then it works fine. I’m not sure why I would ever want to use plugins in that case, since I could only be declaring plugins that would be loaded anyway, without the declaration