问题
When I try to execute a test on reactjs with jest, it always return me the error: I have correctly install Jest, I have try to remove import but it do an error with the next.
App.test.js:
import React from 'react';
import {shallow }from 'enzyme';
import renderer from 'react-test-renderer';
import ReactDOM from 'react-dom';
import App from './App.js';
import User from './Modules/User.js';
const user = {
email: "test@gmail.com",
first_name: "test",
last_name: "test"
}
test('Users renders properly', () => {
const wrapper = shallow("<User users={user}/>");
const element = wrapper.find('input');
});
If it doesn't say error for import, it don't recognise shallow when I set shallow();
Feel free to ask for more detail.
回答1:
You must change jest to react-scripts test --env=jsdom in npm test
来源:https://stackoverflow.com/questions/51261252/jest-unexpected-identifier-react