Search code examples
node.jsgruntjskarma-runnerkarma-coverage

`Can not load "coverage"!` message when trying to run Karma Coverage


The reason I raise this question is because the only Q/As I can find on StackOverflow is to do with the plugin not being found, where the solution is to add to the list of plugins. However, this is different, as the plugin is being found successfully but failing to load anyway.

I'm not sure what I need to change or do to get coverage to run successfully.

Below is the output I get when I try to run a coverage task through Grunt.

Running "karma:unit_coverage" (karma) task
INFO [karma]: Karma v0.10.10 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
WARN [preprocess]: Can not load "coverage"!
  TypeError: Object function lodash(value) {
      // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
      return (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__'))
       ? value
       : new lodashWrapper(value);
    } has no method 'includes'
    at createCoveragePreprocessor (/home/jon/dev/romonet/portal/node_modules/karma-coverage/lib/preprocessor.js:56:10)
    at Array.invoke [as 0] (/home/jon/dev/romonet/portal/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at get (/home/jon/dev/romonet/portal/node_modules/karma/node_modules/di/lib/injector.js:48:43)
    at instantiatePreprocessor (/home/jon/dev/romonet/portal/node_modules/karma/lib/preprocessor.js:40:37)
    at Array.forEach (native)
    at /home/jon/dev/romonet/portal/node_modules/karma/lib/preprocessor.js:57:29
    at /home/jon/dev/romonet/portal/node_modules/karma/lib/file-list.js:196:17
    at Object.oncomplete (fs.js:107:15)

Below are my installed versions of packages:

├─┬ grunt-karma@0.6.2
├─┬ karma@0.10.10
├─┬ karma-coverage@0.5.5

Solution

  • As expected, it was a version dependency issue. Downgrading karma-coverage to version ~0.1.5 remedied the problem.