How to fix "SyntaxError: Unexpected identifier" on Enzyme from configs in jest.setup.js How to fix "SyntaxError: Unexpected identifier" on Enzyme from configs in jest.setup.js typescript typescript

How to fix "SyntaxError: Unexpected identifier" on Enzyme from configs in jest.setup.js


From your jest.config.js you are not parsing .js files (jest.setup.js where the error comes from)

Modifying this line :

transform: {    '^.+\\.(ts|tsx)?$': `<rootDir>/jest-preprocess.js`  },

to add .js extensions like so:

transform: {    '^.+\\.(ts|tsx|js)?$': `<rootDir>/jest-preprocess.js`  },

Should do the trick.

Also, importing Adapter like this will throw an error

import * as Adapter from 'enzyme-adapter-react-16'

use this instead

import Adapter from 'enzyme-adapter-react-16'