enzyme react js code example
Example 1: enzyme react
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new Adapter() });
Example 2: react enzyme
import { configure } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import { shallow, mount, render } from 'enzyme'
import renderer from 'react-test-renderer'
configure({ adapter: new Adapter() })
global.shallow = shallow
global.mount = mount
global.render = render
global.renderer = renderer
Example 3: enzyme react
npm i --save-dev enzyme enzyme-adapter-react-16
Example 4: react enzyme
step by step how to fix enzyme-adapter-react-16 not support for React version 17
step one : npm i npm-install-peers -g
step two copy this :
"peerDependencies": {
"react": "^16.13.1",
"react-dom": "^16.13.1"
}
step three: typing in your terminal npm-install-peers