No coverage information was collected, exit without writing coverage information
Closed this issue · 8 comments
I try to use grunt-mocha-istanbul, but it always show me "No coverage information was collected, exit without writing coverage information".
my grunt config
module.exports = (grunt) ->
grunt.config.set 'mocha_istanbul',
coverage:
src: 'test/controllers/'
options:
coverageFolder: 'coverage'
root: 'api/'
grunt.loadNpmTasks 'grunt-mocha-istanbul'
return
project use sails.
what version of mocha and istanbul are you using? are you executing the tests using coffeescript? or trying to coverage .coffee files?
also, are you forking a process? if so, you need to set istanbulOptions: ['--hook-run-in-context']
also, is there anything in the coverage
folder?
I use mocha 1.18.2, istanbul 0.3.17.
I try to use new config with mocha 2.2.5, following:
module.exports = (grunt) ->
grunt.config.set 'mocha_istanbul',
coverage:
src: 'test/controllers/'
options:
coverageFolder: 'coverage'
istanbulOptions: ['--hook-run-in-context']
mask: '**/*.spec.coffee'
root: 'api/'
grunt.loadNpmTasks 'grunt-mocha-istanbul'
return
but coverage folder also is empty.
Result also is "No coverage information was collected, exit without writing coverage information".
istanbul can't instrument .coffee
files by default, for that you need to use ibrik.
set your scriptPath
to the ibrik command line bin, like:
options:
scriptPath: require.resolve('ibrik/bin/ibrik')
mochaOptions: ['--compilers coffee:coffee-script/register']
I try to use ibrik, But it not work too.
I new a project to try this issue.
https://github.com/Negaihoshi/sails-starter-toolkit/blob/master/tasks/config/mocha_istanbul.coffee
well, there are no controllers in your project, it can't generate coverage from it, or did you create that repo just to show the task file?
you could try setting
options:
recursive: true
sorry, I forgot add controller action in the project.
I add controller action now.
I fallow this website to setting my project.
http://thenullpointer.in/2014/09/08/Testing-and-code-coverage-using-grunt-mocha-istanbul-in-Sails-js/index.html
And it not work too.
https://github.com/Negaihoshi/sails-starter-toolkit/blob/master/tasks/config/mocha_istanbul.coffee
it should be
module.exports = (grunt) ->
grunt.config.set 'mocha_istanbul',
coverage:
src: 'test'
options:
coverageFolder: 'coverage'
recursive: true
istanbulOptions: ['--hook-run-in-context']
scriptPath: require.resolve('/Users/negaihoshi/.nvm/versions/io.js/v1.8.1/bin/ibrik') # line changed
mask: '**/*.spec.coffee'
root: 'api/'
grunt.loadNpmTasks 'grunt-mocha-istanbul'
return
also, is the bootstrap.test.coffee
being called prior to the task execution? is it needed?
reopen if needed