karma-coverage installed, but preprocess says "coverage" is not registered.

4,809 views
Skip to first unread message

David Karr

unread,
Oct 2, 2013, 6:38:30 PM10/2/13
to karma...@googlegroups.com
I'm working through a POC with Karma, Jasmine, AngularJS, and Maven.  I'm on a Win7 box with Cygwin installed.

I've done all of my npm installs in a cmd window, but I'm running my Maven build in a Bash shell in Cygwin.

The unit test is executing and succeeding, but when I tried to implement coverage, it says:
WARN [preprocess]: Can not load "coverage", it is not registered!


Here is my "karma.conf.js" file:
module.exports = function(config) {
  config
.set({
    basePath
: '',
    frameworks
: ['jasmine'],
    files
: [
     
"../../../../src/test/webapp/js/libs/angular.js",
     
"../../../../src/test/webapp/js/libs/angular-mocks.js",
     
"../../../../src/main/webapp/js/*.js",
     
"../../../../src/test/webapp/js/*.js"
   
],
    exclude
: [
   
],
        preprocessors
: {
           
"../../../../src/main/webapp/js/*.js": ['coverage']
       
},
        coverageReporter
: {
            type
: "lcov",
            dir
: "target/"
       
},
    reporters
: ['dots', 'junit', 'coverage'],
    port
: 9876,
    colors
: false,
    logLevel
: config.LOG_DEBUG,
    autoWatch
: false,
    browsers
: ['PhantomJS'],
    captureTimeout
: 60000,
    singleRun
: true
 
});
};


My "npm list" output shows that I have "karma-c...@0.1.0".

I'm using the Karma maven plugin, but the resulting command line looks like this:

cmd /C karma start ...\angularjsexp\src\test\webapp\js\karma.conf.js --browsers PhantomJS --reporters dots,coverage --single-run --no-auto-watch --colors false



David Karr

unread,
Oct 3, 2013, 1:00:12 PM10/3/13
to karma...@googlegroups.com


On Wednesday, October 2, 2013 3:38:30 PM UTC-7, David Karr wrote:
I'm working through a POC with Karma, Jasmine, AngularJS, and Maven.  I'm on a Win7 box with Cygwin installed.

I've done all of my npm installs in a cmd window, but I'm running my Maven build in a Bash shell in Cygwin.

The unit test is executing and succeeding, but when I tried to implement coverage, it says:
WARN [preprocess]: Can not load "coverage", it is not registered!



Ok, I appear to have gotten past this.  It appears I needed to explicitly list the plugins I'm going to be using, like this:
    plugins:[
             
'karma-jasmine',
             
'karma-coverage',
             
'karma-phantomjs-launcher'
             
],



 I'm still having other issues, which I'll ask in a new question.

Vojta Jína

unread,
Oct 6, 2013, 8:36:58 PM10/6/13
to karma...@googlegroups.com
Yep. Also, by default, Karma loads all the plugins that are its siblinks. So if you follow "the recommended" way, having local npm modules (basically a package.json per project, where you list karma and all the plugins you need), it should work without defining "plugins".

V.


--
You received this message because you are subscribed to the Google Groups "karma-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to karma-users...@googlegroups.com.
To post to this group, send email to karma...@googlegroups.com.
Visit this group at http://groups.google.com/group/karma-users.
For more options, visit https://groups.google.com/groups/opt_out.

David Karr

unread,
Oct 7, 2013, 10:04:33 AM10/7/13
to karma...@googlegroups.com
Would you mind giving me some resources that talk about "package.json" without assuming that you have experience with node.js, and that describe how to actually use it?  I've seen numerous articles about how to create it, and what's in it, but I can't find any obvious mention of how I use it, directly or indirectly, from my karma maven plugin reference.


--
You received this message because you are subscribed to a topic in the Google Groups "karma-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/karma-users/7SqpqBC3oms/unsubscribe.
To unsubscribe from this group and all its topics, send an email to karma-users...@googlegroups.com.

To post to this group, send email to karma...@googlegroups.com.
Visit this group at http://groups.google.com/group/karma-users.

Vojta Jína

unread,
Oct 12, 2013, 8:39:39 PM10/12/13
to karma...@googlegroups.com
package.json is "metadata" file for NPM, so typically you put a package.json in your project and list there all your dependencies. Then anybody who wants to work on the project can just do `npm install` and it does install all the dependencies.

This section of Karma docs talks about it a bit:

Hope this helps,
V.




Reply all
Reply to author
Forward
0 new messages