I get the following error when using Jest with Antd, React and Parcel. Jest complains about the Antd css file. Should Jest even include node_modules by default? And if not, is it possible to exclude it?
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 > plain JavaScript.
{ProjectPath}/node_modules/antd/lib/style/index.css:5
.ant-modal,
^
SyntaxError: Unexpected token '.'
8 |
9 |
> 10 | export default () => {
jest.config.js
{
"jest": {
"setupFilesAfterEnv": [
"<rootDir>src/setupTests.js"
],
"transform": {
"^.+\\.js$": "babel-jest",
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub"
}
}
}
.babelrc
{
"presets": [
"@babel/preset-react",
"@babel/preset-env"
],
"plugins": [
[
"import",
{
"libraryName": "antd",
"style": "css"
}
]
]
}
.lessrc
{
"javascriptEnabled": true
}