grunt-karma
grunt-karma copied to clipboard
Coverage does not seem to work when running grunt-karma with background
I am trying to setup a grunt-based project to use karma with code coverage enabled. For some reason this doesn't seem to be working.
I have setup a sample project that shows the issue: https://github.com/abierbaum/test_karma/tree/dev/add_grunt
If I run:
./node_modules/grunt build
Then it will run in singleRun mode and the following output as expected.
~/Source/test_karma (dev/add_grunt *% u=)$ ./node_modules/.bin/grunt build
Running "clean:dist" (clean) task
Running "copy:dist" (copy) task
Copied 3 files
Running "jshint:files" (jshint) task
>> 5 files lint free.
Running "karma:build" (karma) task
[2013-06-25 16:25:24.812] [DEBUG] config - autoWatch set to false, because of singleRun
INFO [karma]: Karma server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 28.0 (Linux)]: Connected on socket id wy4fHhIWpvTmRdOnOhDY
Chrome 28.0 (Linux) LOG: 'play file: '
Chrome 28.0 (Linux) LOG: { currentlyPlayingSong: {}, isPlaying: true }
Chrome 28.0 (Linux): Executed 5 of 5 SUCCESS (0.028 secs / 0.007 secs)
=============================== Coverage summary ===============================
Statements : 93.33% ( 14/15 )
Branches : 100% ( 2/2 )
Functions : 85.71% ( 6/7 )
Lines : 93.33% ( 14/15 )
================================================================================
Running "concat:dist" (concat) task
File "dist/karma_test.js" created.
Running "uglify:dist" (uglify) task
File "dist/karma_test.min.js" created.
Done, without errors.
If instead I try to run using a watch and background: true, I get the following output where karma works, but it doesn't run the coverage.
~/Source/test_karma (dev/add_grunt *% u=)$ ./node_modules/.bin/grunt dev
Running "clean:dist" (clean) task
Cleaning "dist/"...OK
Running "copy:dist" (copy) task
Copied 3 files
Running "jshint:files" (jshint) task
>> 5 files lint free.
Running "concat:dist" (concat) task
File "dist/karma_test.js" created.
Running "uglify:dist" (uglify) task
File "dist/karma_test.min.js" created.
Running "karma:unit" (karma) task
Running "watch" task
Waiting...OK
>> File "spec/PlayerSpec.js" changed.
Running "clean:dist" (clean) task
Cleaning "dist/"...OK
Running "copy:dist" (copy) task
Copied 3 files
Running "jshint:files" (jshint) task
>> 5 files lint free.
Running "concat:dist" (concat) task
File "dist/karma_test.js" created.
Running "uglify:dist" (uglify) task
File "dist/karma_test.min.js" created.
Running "karma:unit:run" (karma) task
Chrome 28.0 (Linux) LOG: 'play file: '
Chrome 28.0 (Linux) LOG: { currentlyPlayingSong: {}, isPlaying: true }
Chrome 28.0 (Linux): Executed 5 of 5 SUCCESS (0.026 secs / 0.01 secs)
Done, without errors.
Completed in 0.774s at Tue Jun 25 2013 16:27:50 GMT-0500 (CDT) - Waiting...
Any idea how to fix this up?
I am running Ubuntu 12.10 with node v0.10.12. The package versions I am using are shown in the package file: https://github.com/abierbaum/test_karma/blob/dev/add_grunt/package.json
Having the same issue. Would be nice to see coverage in background mode.
@abierbaum thanks for putting a sample together, I'll take a look.
@abierbaum ok I see what you're seeing. Could you do me a favor in that sample project: create a branch that uses grunt-karma
v 0.5.x (uses latest karma)? Would like to rule that out before digging further.
@geddski I was having the same problem and the update seemed to do the trick.
Thank you.
I had a look at the at the sample of @abierbaum that used karma v 0.5.x https://github.com/abierbaum/test_karma/tree/dev/karma_canary and the coverage report is generated by a 'singleRun' task. Has anyone managed to generate the coverage reports when grunt-karma is running in 'background: true' mode?
In my experience using an outdated version is what causes this. Currently I'm using version 0.10.9 of Karma, version 0.1.5 of Karma Coverage and version 0.6.2 of the Grunt Karma plugin; using these versions I succeed in creating coverage reports when the background mode has been activated.
The NPM version that I'm running is 1.3.23.
I still see this same issue with
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
,karma: {
unit: {
configFile: "test/karma.conf.js",
background: true
}
,ci: {
configFile: "test/karma.conf.js",
singleRun: true
}
}
I get coverage output with the ci
target, but not the unit
one (run as grunt karma:unit watch
).
@NShewmaker can you please check if this might be related to #33 where you were seeing that background=false
was passed even though you specified true
.
:+1: I'd love to see updated coverage reports in console when tdd-ing