using with the require hook
jonathanong opened this issue · 5 comments
i noticed that if i use this or istanbul with babel's require hook, it does not report the coverage correctly. http://babeljs.io/docs/usage/require/
do you know how to get around that?
I always run tests with babel-node instead of node, which manages the require hook automatically. I think it ultimately has to do with multiple processes and how istanbul handles those. What is your test command?
ah i c. i'm reluctant to use babel-node
because it makes all the test commands a little more confusing, and i'd prefer to just one day remove the require hook vs. rewriting all the test commands.
currently, this is what i have, which worked until i used the node require hook.
{
"scripts": {
"test": "./bin/reseed && NODE_ENV=test mocha lib/__tests/index.js server/__tests/index.js",
"test-cov": "./bin/reseed && NODE_ENV=test istanbul cover node_modules/mocha/bin/_mocha -- lib/__tests/index.js server/__tests/index.js"
}
}
do you mind adding your test commands to the readme? that would be super helpful.
sidenote: would be nice if you did babel: '^6.0.0'
as there are various bugs in 6.0
that were fixed in 6.1
. https://github.com/ambitioninc/babel-istanbul/blob/c58405488ed18ca4fe2c72bf0fa403f6444a9f4e/package.json#L91
I'll bump babel. I haven't published any test commands because everyone is going to have a different setup. Each person needs to understand their test requirements and how each of the tools they use interact with each other. In this case, I believe it is impossible to use the require hook and istanbul in the way that you want because of how instabul works.
I think your command will work if you do something like this:
./bin/reseed && NODE_ENV=test babel-node node_modules/.bin/babel-istanbul cover node_modules/.bin/_mocha -- lib/__tests/index.js server/__tests/index.js
cool thanks