I'm trying to set up a React module with tests. I'm using rollup to compile everything, which works fine. But I'm trying to introduce testing as well.
My directory structure:
dist/
|- index.js
src/
|- .babelrc
|- util.js
test/
|- .babelrc
|- util.test.js
rollup.config.js
So far, so good. I have a .babelrc in src that applies to my source files:
{
"presets": [
["es2015", { "modules": false }],
["env", { "modules": false }],
"react"
],
"plugins": ["external-helpers"]
}
and a separate one for the Jest tests, which doesn't have the exceptions Rollup requires:
{
"presets": ["es2015", "env", "react"]
}
Unfortunately, I get an error when I run the tests, complaining about the very first es6 feature they run in to in the source file (SyntaxError: Unexpected token export). If I remove the module exception, then the test passes, but Rollup fails.
How do I get babel to apply the module exceptions for Rollup, but not for Jest? Or is there an entirely different way I should be configuring these?