istanbul
istanbul copied to clipboard
No coverage information was collected, exit without writing coverage information
1.git clone https://github.com/lizhexia/ramlev.git
2.cd ramlev and npm install
3. istanbul cover npm test
error :No coverage information was collected, exit without writing coverage information
what can i do for this question ,why can't work ?
same question. this error message does not help me figure out what to do.
I've been digging around into istanbul for the last hour or so because I've been having the same issue. It works for all of my repos except for one new project. I'm not positive, but I believe it might be because istanbul uses the require
and module loading mechanisms of node to run code coverage. Because your tests are being tested like a cli
, it doesn't use require, at least in the same process. Again, please someone correct me if I'm wrong or misunderstand the way istanbul works. I haven't looked at the entire codebase to know how all of the moving parts work.
The issue that I am having is different. At the top of my tests, I require 3 modules:
var expect = require('expect.js');
var metalsmith = require('metalsmith');
var globMeta = require('../');
globMeta
is the module I want to actually test. When I start digging through all of the files registered through istanbul, I notice all of the expect.js
stuff and the metalsmith
stuff, but not my globMeta
module. Oddly, to fix it, I just needed to move my globMeta
module requiring up higher on the list of requires.
Although my issue only relates to yours by Error Message only, it would still be good to make this issue known to the maintainer.
watch out for forking. I resolved this problem by discovering that something was forking a child process to run node code and that's why it didn't get covered.
If anyway wants to know how to use Istanbul with forked tests, you can look at the "mysql" module, which runs every test in it's own fork, but correctly collects coverage anyway.
If anyone is using mocha, use the "underscored" _mocha
command instead of mocha
. If you're using package.json run-scripts, simply do something like this:
{
"scripts": {
"test": "mocha",
"test-cov": "istanbul cover _mocha"
}
}
I had the same message, but quite a different problem. I’m transpiling ES6 code to ES5 with babel. I want to run the tests in an ES5 environment, so I compile them into a directory called .es5
before testing.
It turns out that while istanbul cover .es5/test.js
results in the same message as above, cd .es5 && istanbul cover test.js
is OK.
Hope this helps someone :)
I'm getting the same message running Jasmine tests from the command line (not the Jasmine-Node package, but just plain old Jasmine, running under iojs). I have npm test
wired to run jasmine
. When I run
istanbul cover npm test
I get this same error message. When I just run istanbul cover jasmine
it works fine. I wish I could suggest a solution but I haven't reached a resolution, so I really can't at this point. Hopefully what I've shared can help track down the problem, if indeed this is a problem and not expected behavior.
EDIT: I feel stupid for not realizing this before I wrote, but this code works perfectly:
npm test --coverage
Hopefully this can help someone else.
@danascheider Running istanbul cover npm test
isn't the proper way to run it.
You should add "scripts": { "test": "istanbul cover jasmine" }
in your package.json to get npm test
to run the coverage.
Thank you, I found that out.
@zaim - thanks, the underscore worked for me!
Using babel-register getting:
No coverage information was collected, exit without writing coverage information
I am currently doing "test": "./node_modules/.bin/istanbul cover ./node_modules/.bin/mocha"
and doesn't work. When I used _mocha
does work, but.
Why do I have to use _mocha
? Answer #436 Basically _mocha
is the real mocha
executable. mocha
is a wrapper for that executable.
@carlitux were you able to get istanbul
working with babel
...?
@nelsonic no, I wasn't.
@carlitux sad times... :cry:
we are experimenting with: https://github.com/ambitioninc/babel-istanbul
so far it looks quite promising ...
see: https://travis-ci.org/dwyl/ampl/builds/103683244#L297
If you find an alternative way of running ES6 code through istanbul
(standard version) _please_ let us know! :+1:
@nelsonic thanks babel-istanbul is working for me... I hope both projects can merged soon
I'm getting the same No coverage information was collected, exit without writing coverage information
for both istanbul and babel-istanbul
@cameronjroe I am using in this way.
./node_modules/.bin/babel-node node_modules/.bin/babel-istanbul cover node_modules/.bin/_mocha --report text --check-coverage -- --timeout 5000 -u tdd --recursive app/tests frontend/javascript/tests
Yeah, I actually found that out too. Thanks @carlitux
For some reason it's not running on travis-ci. Have you had this issue?
@cameronjroe please add a link to the build on travis-ci
where the coverage is not being collected so people can help you debug why its not working...
https://travis-ci.org/cameronjroe/founders-names#L138
The answer here by @zaim and the answer here by @yordis identified the solution (or rather lack of understanding) that worked for me.
Thanks. I update istanbul
to 1.x
and solve the issue.
@creeperyang this use babel-node? what is the command to use istanbul instead of istanbul-babel...
@carlitux I just use [email protected]
.
command is like:
"test-cov": "node_modules/.bin/babel-node node_modules/.bin/istanbul cover --dir test/coverage test/run.js"
And my repo: https://github.com/creeperyang/ysprite
👍 for [email protected]
@zaim That works for me! Thx~ :+1:
:+1 for [email protected]
+1 for [email protected]
:+1: