I am trying to write a test using Jest and import an es6 module. I am currently using webpack3 and jest 21.0.2. My test code starts with
import Const from 'Util/Const';
This throws an error "SyntaxError: Unexpected token import". I have development.webpack.config.js and production.webpack.config.js files for development and production build. webpack.config.js files basically reads env variable and determines which file to refer.
Below code is a part of development.webpack.config.js to handle this error:
env: {
test: {
presets:['react',["es2015"]],
plugins: ["transform-es2015-modules-commonjs", "dynamic-import-node"]
}
}
It seems like when I run npm test, Jest is not referring to development.webpack.config.js. Is there any way to set specific webpack config file when running Jest?