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: "[email protected]",
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.
You must change jest
to react-scripts test --env=jsdom
in npm test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With