If I use import/export from ES6 then all my Jest tests fail with error:
Unexpected reserved word
I convert my object un
I encountered the same issue.
These are what I did:
yarn add --dev babel-jest @babel/core @babel/preset-env
Make file jest.config.js in rootDir.
module.exports = {
moduleFileExtensions: ["js", "json", "jsx", "ts", "tsx", "json"],
transform: {
'^.+\\.(js|jsx)?$': 'babel-jest'
},
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '/$1'
},
testMatch: [
'/**/*.test.(js|jsx|ts|tsx)', '/(tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx))'
],
transformIgnorePatterns: ['/node_modules/']
};
Then make file babal.config.js in rootDir.
Go like this:
module.exports = {
"presets": ["@babel/preset-env"]
}