Closed hax closed 8 years ago
The library istanbul ignores the test
directory by default. If you don't want coverage on the test files, you need to tell istanbul to ignore the es5-test
directory. It might look something like babel-istanbul cover --ignore=es5-test cover _mocha -- test --ui tdd
, but I have not tested that out.
Alternatively, you could do what I do and just run all your tests with babel-node. That will compile everything on the fly and you no longer need another folder for compiled tests: babel-node node_modules/.bin/babel-istanbul cover _mocha -- test --ui tdd
I'm not sure about the inline sourcemaps. I would opt to not use inline sourcemaps for testing.
Thank you @jmcriffey , babel-node node_modules/.bin/babel-istanbul cover _mocha -- test --ui tdd
works for me.
BTW, I forgot to report babel-istanbul cover mocha -- test --ui tdd --compilers js:babel/register
also generate the lcov, but it shows the compiled code with the locations of source...
It seems that babel-istanbul require the tests written in ES5, or pre-compile the tests. And if pre-compile, the test files will be included in coverage...
Some details:
My script is like
babel-istanbul cover _mocha -- test --ui tdd
and error:So I precompile the tests via
babel --out-dir es5-test test
, runbabel-istanbul cover _mocha -- es5-test --ui tdd
, it's ok butes5-test
also listed in the coverage which surprise me.BTW, it seems babel-istanbul will throw if the test files contains inline sourcemaps.