Istanbul: Istanbul doesn't work with Babel > 6

Created on 17 Nov 2015  路  6Comments  路  Source: gotwarlost/istanbul

I spent a couple of hours on it and looks like istanbul doesn't work with Babel > 6 transpiling.

I created a sample repo with 3 branches:

  • master (with babel > 6 dependency)
  • babel5 (with babel 5 dependency)
  • commonjs (with no transpiling)

With babel 5 & commonjs branches I was able to generate some coverage with istanbul using:

npm run coverage-report

However looks like ES6 import statements are just ignored with babel > 6.

Am i missing something obvious or it can be related to this change ?

Thank you.

PS:
don't forget to rm -rf node_modules when switching branches.

Most helpful comment

On babel 6.4.5, and was only able to get it to work upgrading to "istanbul": "^1.0.0-alpha.2"
here is the command we are using:
"test-coverage": "istanbul cover node_modules/.bin/_mocha -- -u exports --compilers js:babel-register -R spec && open ./coverage/lcov-report/index.html"

All 6 comments

Doesn't work using --es-modules option neither btw.

I realized that require('babel-core/register'); was the issue. Looks like babel had in its 5.x branch the following patch to deal with istanbul's hook.

For the 6.x branch looks like there's an opened PR which seemed to be related to the issue.

Anyway the only working solution right now seems to be use babel-node instead of require('babel-core/register'); so the babel's hook will be applied first and won't override istanbul one.

So I was finally able to make it works using isparta and the following commands:

  "scripts": {
    "test": "mocha --compilers babel:babel-core/register",
    "coverage-report": "babel-node node_modules/.bin/isparta cover _mocha"
  }

@jails: according to that babel PR, they think it should be fixed in istanbul, and there was a dirty monkey-patch suggestion.

EDIT: Sorry, hit the wrong button. Is there a way we could add such a think to istanbul?

@jails, do you still have those examples repos around? Having an example would be a huge help to folks trying to get these tools to play together :)

I have the same issue after upgrade babel to 6.

Have to use babel-node and it works. Any idea we can resolve it?

On babel 6.4.5, and was only able to get it to work upgrading to "istanbul": "^1.0.0-alpha.2"
here is the command we are using:
"test-coverage": "istanbul cover node_modules/.bin/_mocha -- -u exports --compilers js:babel-register -R spec && open ./coverage/lcov-report/index.html"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

olalonde picture olalonde  路  3Comments

ORESoftware picture ORESoftware  路  4Comments

ChrisPearce picture ChrisPearce  路  3Comments

lobabob picture lobabob  路  3Comments

Ratikant01 picture Ratikant01  路  3Comments