jeffrifwald / babel-istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
144 stars 23 forks source link

Report is transpiled babel #25

Closed TomFrost closed 8 years ago

TomFrost commented 8 years ago

Hi there! I was very excited about this package, expecting my istanbul coverage report to switch from showing me already-transpiled code to my original ES6 source, but unfortunately when I drop-in-replaced this...

istanbul cover node_modules/.bin/_mocha -- --compilers js:babel/register ./test/src --recursive

into this...

babel-istanbul cover node_modules/.bin/_mocha -- --compilers js:babel/register ./test/src --recursive

I still saw post-transpilation code. Am I misunderstanding what the effects are this library are, or am I using it incorrectly?

Thanks for your help and time!

jeffrifwald commented 8 years ago

I've actually never tried to use babel-istanbul with the --compilers flag with mocha. Since mocha is doing the compiling with that flag enabled, it looks like all of the work babel-istanbul does is actually defeated. I assume babel-istanbul is being fed code that is already compiled.

Here is how I usually run my tests:

babel-node node_modules/.bin/babel-istanbul cover node_modules/.bin/_mocha -- ./test/src --recursive

Using babel-node will allow you to run your code, but babel-istanbul will also be able to read the original source instead of the already compiled mocha source. Using this method, I only see my original source in coverage files.

Let me know if that works out for you. Thanks.

TomFrost commented 8 years ago

Brilliant! Thanks for the tip, everything looks great now. Excellent work on this :)