babeljs - How do I get Jest to run tests against a rollup+babel build? -
i'm trying set react module tests. i'm using rollup compile everything, works fine. i'm trying introduce testing well.
my directory structure:
dist/ |- index.js src/ |- .babelrc |- util.js test/ |- .babelrc |- util.test.js rollup.config.js so far, good. have .babelrc in src applies source files:
{ "presets": [ ["es2015", { "modules": false }], ["env", { "modules": false }], "react" ], "plugins": ["external-helpers"] } and separate 1 jest tests, doesn't have exceptions rollup requires:
{ "presets": ["es2015", "env", "react"] } unfortunately, error when run tests, complaining first es6 feature run in in source file (syntaxerror: unexpected token export). if remove module exception, test passes, rollup fails.
how babel apply module exceptions rollup, not jest? or there entirely different way should configuring these?
i have managed solution this, don't , love more transparent one.
my test/.babelrc (with no module exceptions) @ root level of project.
in rollup.config.js, have set rollup-plugin-babel ignore babelrc, , given options in src/.babelrc:
babel({ babelrc: false, presets: [ ['es2015', { modules: false }], ['env', { modules: false }], 'react', ], plugins: ['external-helpers'], exclude: 'node_modules/**', }), this seems work, having .babelrc @ root level isn't used in compiling package seems recipe confusion later down line. surely there better way?
Comments
Post a Comment