1
votes

I have a problem with react, jest and enzyme configuration. So basically I have installed dependencies like jest, jest-cli, babel-jest, enzyme and enzyme-adapter-react-16. I also have setupTest.js which looks like this:

import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

But I don't know why I am still getting an error Unexpected token import because of this line: import { configure } from 'enzyme'

Any solutions ?

1
your configurations seems right but the way you run tests seems to have issue - Fadi Abo Msalam
I run them with npm test and my script looks like "test": "jest" - SimpleCoder
are you using create react app ? - Fadi Abo Msalam

1 Answers

-1
votes

Hack around this, I formatted the code to:

const Enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');
Enzyme.configure({ adapter: new Adapter() })