Jest es6 modules: unexpected module import
As node does not support modules you have to compile your files using Babel. Have a look at the docs on how to configure Jest and Babel
- Install required dependencies:
yarn add --dev babel-jest @babel/core @babel/preset-env
or
npm install --save-dev babel-jest @babel/core @babel/preset-env
- Create
babel.config.js
in your main folder and paste it there:
// babel.config.js
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
],
};
- Make sure all your jest settings in
package.json
andjest.config.js
are set to default.