Closed damusnet closed 8 years ago
Are you excluding something that needs to be transpiled by accident? Maybe try excluding something with a very distinct name, other than libs
and see if you have the same problem.
I also tried with another directory named shims
that contains nothing of importance, and the error is the same. It does not seem related to me. I more feels like the -x
deactivates babel at some level (cf SyntaxError: Unexpected reserved word
=> import
).
Yeah that is weird, I'm seeing the same problem. I don't know enough about istanbul to know why it would do that. It might be doing some really weird stuff with the excludes. I've always had trouble with Istanbul and exludes/includes in general. I've just learned to structure my code so the built in excludes work.
The other weird stuff is that the same -x '**/lib/**'
worked fine without babel-node
but then I had coverage on the transpiled code instead of the ES6 code.
I think the issue is that babel isn't being run on the excluded files.
I have my test files in same directory as the app as *.spec.js
files. Where I'm running into the issue is trying to exclude my tests from the report. Since my tests are also written in ES6 it fails because my tests don't get compiled.
I figured out how to get this to work. A bit of a crude work-around, bit it works. This is what I'm doing now:
.istanbul.yml
:
verbose: false
instrumentation:
root: ./app
excludes: ["*.spec.js"]
include-all-sources: true
reporting:
reports:
- html
test/mocha.opts
:
-r ./test/babel-register.js
--recursive
./app/**/*.spec.js
test/babel-register.js
:
if (/\bin\/_mocha/.test(process.argv[1])) {
require("babel-core/register")({
only: /\.spec\.js$/
});
} else {
require("babel-core/register");
}
Both mocha
and babel-istanbul cover -- ./node_modules/.bin/_mocha
work.
The following .istanbul.yml also did the trick for me:
verbose: false
instrumentation:
root: ./src/app
excludes: ["**/lib/**"]
include-all-sources: true
reporting:
reports:
- html
I discarded this possibility too early because it wasn't clear to me how to turn on the include-all-sources
setting from the documentation. Weird though that this would work, and not the inline command line solution.
Hello,
This works:
babel-node node_modules/.bin/babel-istanbul cover --include-all-sources --root 'src/app' node_modules/.bin/_mocha
While this doesn't:
babel-node node_modules/.bin/babel-istanbul cover --include-all-sources --root 'src/app' -x '**/lib/**' node_modules/.bin/_mocha
It fails with this error:
Do you have any idea what is happening?