Enzyme Method Not Found (React Testing)
Error message
TypeError: wrapper.find(...).simulate is not a function
Quick summary
The test uses Enzyme APIs (find, simulate, shallow) but Enzyme is not installed, not configured, or the method doesn't exist on the wrapper.
Why this happens
Enzyme is not installed in the project.
Enzyme adapter for the React version is not configured.
The method doesn't exist on the wrapper type (shallow vs mount).
Migrating from Enzyme to React Testing Library but still using Enzyme APIs.
Minimal example
import { shallow } from 'enzyme';
// enzyme not installed
const wrapper = shallow(<Component />);
wrapper.find('button').simulate('click'); // TypeError// Migrate to React Testing Library
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
render(<Component />);
await userEvent.click(screen.getByRole('button'));Migrate from Enzyme to React Testing Library, which is the modern standard.
How to diagnose
Check if enzyme and enzyme-adapter-react-N are in package.json.
Check if the Enzyme adapter is configured (enzyme.configure({ adapter: new Adapter() })).
Verify the method exists on the wrapper type being used.
Consider migrating to React Testing Library (recommended for modern React).
How to fix
Install Enzyme and the correct adapter: npm install --save-dev enzyme enzyme-adapter-react-18.
Configure the adapter in a setup file.
Or migrate to React Testing Library: use render, screen.getByRole, userEvent instead.
How to prevent
For new React projects, use React Testing Library instead of Enzyme.
If using Enzyme, ensure the adapter matches your React version.
Related Resources
Related Glossary
Related Lessons
- React Testing
Testing React components.