Hello,
I tried the current command to have cover information for a test using a module written using es6.
I use https://github.com/domenic/mocha-traceur.
node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha -- --compilers js:mocha-traceur -u exports -R spec test/test.js
also with --hook-run-in-context
All tested pass, but at the end I get 'No coverage information was collected, exit without writing coverage information'
Any idea?
(I confirm that this doesn't work for me either.)
There is a branch of istanbul for harmony support and I believe someone has created a package for it. This is needed because esprima mainline does not (or, did not at that time) support es6.
I've tried using the harmony branch and that solved my problem! Thanks for pointing it out
Closing this since the harmony branch is being developed on.
see https://github.com/gotwarlost/istanbul/blob/master/CHANGELOG.md
since v0.3.9 :
Hi guys, the harmony branch should be treated as obsolete with the latest Istanbul release. The mainline release now has all the features that the harmony branch has. Let me know is thus is not the case.
I'm still getting "No coverage information was collected, exit without writing coverage information" in an es6/babel project.
Using 0.3.17 with this command:
istanbul cover node_modules/.bin/mocha -- --compilers js:babel/register
Try _mocha instead of mocha which forks and doesn't allow istanbul to instrument the subprocess code as a result.
:+1:
Hello guys.
I'm using it like this:
"test": "mocha --compilers js:babel/register --colors --bail --reporter spec test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --compilers js:babel/register --colors --reporter dot test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --compilers js:babel/register --colors --reporter spec test/",
And travis.yaml
after_script:
- "test -e ./coverage/lcov.info && npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"
However, on the COVERALLS website the lines highlighting seems messed up - it seems to highlight the wrong lines.
Do you have any ideas what might be wrong?
I guess istanbul highlights the transpiled code, but can it highlight pure ES6?
Also, in your examples it uses babel-register which pollutes the scope with polyfills.
Can it be used with babel-require?
Because when you're writing something like array.includes the tests pass, but after some time you find out that your npm module actually doesn't work for your users.
By the way, while browsing babel sources I accidentally saw some register-without-polyfill.js and turns out that it eliminates the Array.prototype.includes is undefined surprises in the browser (after all the tests passed).
"scripts": {
"test": "mocha --compilers js:babel/register-without-polyfill --colors --bail --reporter spec test/",
You might want to add it to the cookbook page
The COVERALLS issue still remains though
I'm on istanbul 0.3.19, with babel 5.1.10 and mocha 2.2.4. None of the commands above (or any other I've tried) are producing any kind of code-coverage for me. I always get the message "No coverage information was collected, exit without writing coverage information." I'm not sure where the best place is to ask, or who to ask...but any help is appreciated.
@JediMindtrick
Rename your JSX files extension to JS
And launch coverage with this comand:
babel-node node_modules/isparta/bin/isparta cover node_modules/mocha/bin/_mocha --
Hope this helps.
For me - this did not help. But updating to [email protected] did.
upgrading to [email protected] indeed fixed it.
For ES6 && Mocha project锛宮y script commands are listed below:
"scripts": {
"compile": "babel --presets es2015,stage-0 -d lib/ src/",
"test": "npm run compile && mocha --compilers js:babel-core/register",
"cover": "istanbul cover node_modules/mocha/bin/_mocha -- --compilers js:babel-core/register --colors --reporter dot test/"
}
Most helpful comment
upgrading to
[email protected]indeed fixed it.