Setting up this adapter in your jest.setup.js file allows any tests created in Jest to know about the Enzyme adapter, and then use Enzyme do its magic to allow you to test JSX and React components. Jest encountered an unexpected token This usually means that you are trying to import a file which Jest cannot parse, e.g. To solve this, you can change your test script to the below: "test": "react-scripts test --transformIgnorePatterns 'node_modules/ (?! By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules". Note: <rootDir> is a special token that gets replaced by Jest with the root of your project. it's not plain JavaScript. Jest encountered an unexpected token This usually means that you are trying to import a file which Jest cannot parse, e.g. So to be clear, I've followed the instructions to include 2 lines in my setup file, AND included the transformIgnorePatterns you suggested. You could do this manually in each test file, but setting it up here allows you to setup once and gain access in all tests. FAIL src/components/Link.test.js Test suite failed to run 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. By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules". To fix the 'SyntaxError: Cannot use import statement outside a module' with Jest, we need to tell Jest to transpile ES6 modules before we can use them. In order to enable the preset you have to define it in your babel.config.json file, like this: Jest Unexpected Token a.k.a. won't transpile error - Dylan Pierce The Headache Check out our v23.10 to latest version migration guide. it's not plain JavaScript. Most of the time this will be the folder where your package.json is located unless you specify a custom rootDir option in your configuration.. Chai test fail with "Unexpected import token" - JetBrains Jest encountered an unexpected token | QueryThreads I first tried importing it as a ReactComponent: import {ReactComponent as HeartIcon} from . jest unexpected token when importing css The problem is that Jest is hitting these CSS imports and trying to parse them as if they were JavaScript.