I have this excpetion
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it\'s not p
I had a similar error while working on a project with jest, webpack, and vanilla js, so that error is thrown when jest encounters this line of code import '../css/styles.css'; in any /*?.js$/ file. I solved it by moving the jest configurations from the package.json file into a jest.config.js file with the following minimal configuration;
// jest.config.js
module.exports =
"moduleNameMapper": {
"\\.(css|less|scss)$": "identity-obj-proxy"
}
}
Then in babel.config.js
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
],
};