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

drop-in replacement for istanbul? #51

Closed nelsonic closed 8 years ago

nelsonic commented 8 years ago

@jmcriffey which test frameworks have you tried with babel-istanbul ?

we use tape but when attempting to run our tests using babel-istanbul we get the following error: SyntaxError: Unexpected reserved word

We are running the bable-istanbul command using a relative path as we prefer not install node modules globally, thus our test command is:

./node_modules/.bin/babel-istanbul cover ./node_modules/tape/bin/tape ./test/index.js

Please see: https://travis-ci.org/dwyl/ampl/builds/103671132#L278

jeffrifwald commented 8 years ago

I've mostly used mocha, but your testing framework should not affect the coverage unless you are spawning new processes to run tests.

The module babel-istanbul simply compiles files for instrumentation, so you decide how you are going to compile your tests for running. Have you successfully run those same tests without coverage? How are you compiling those test files?

I have always run my tests with babel-node instead of node like so:

./node_modules/.bin/babel-node ./node_modules/.bin/babel-istanbul cover test_command_here
nelsonic commented 8 years ago

@jmcriffey trying that now. (thanks for speedy reply!)

nelsonic commented 8 years ago

@jmcriffey appears to be working... https://travis-ci.org/dwyl/ampl/builds/103683244#L297 thanks again for getting back to us! anyone else using substack's tape for their tests, the command we used is:

./node_modules/.bin/babel-node ./node_modules/.bin/babel-istanbul cover ./node_modules/tape/bin/tape ./test/

And if you are using _mocha_:

./node_modules/.bin/babel-node ./node_modules/.bin/babel-istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- -R spec