Recommended way to strip flow type annotations from tests?
Closed this issue · 3 comments
Hi there. We want to use flow type
annotations in our tests and it appears as if these don't get stripped out before running cover
. We use the babel plugin babel-plugin-transform-flow-strip-types
to strip them from source/tests, but when running babel-istanbul
seems like it only strips it from the source files. This is our .babelrc
e.g.
{ "presets": ["es2015"],
"plugins": ["transform-flow-strip-types"]
}
For the tests we use babel-tape-runner
, and that strips out from both source/tests. Am i doing something wrong? Is there a recommended way to address it? If there isn't I'll just add a step that strips them from the test files before running them though babel-istanbul
. Thanks!
By default, istanbul
ignores the test
directory.
My initial thought is that your test directory is called test
and istanbul
is ignoring it, so babel-istanbul
never knows about it. Can you try to set up custom excludes in your .istanbul.yml
file or changing the name of the test directory and see if that fixes the issue?
Good call. This works although now the test files are included in the coverage report which is not ideal. Is there a way to exclude them from the report? If not, no worries. Thanks for your help.
I'm not sure how babel-tape-runner
works, but I usually run tests with babel-node
instead of node
. That ensures the tests are being compiled and istanbul
doesn't need to know.
Besides that, I think your only options are to precompile or deal with tests in the coverage report.