react18-enzyme-to-rtl
Provides exact Enzyme → React Testing Library migration patterns for React 18 upgrades. Use this skill whenever Enzyme tests need to be rewritten - shallow, mount, wrapper.find(), wrapper.simulate(), wrapper.prop(), wrapper.state(), wrapper.instance(), Enzyme configure/Adapter calls, or any test fil
By github · 795 installs
npx skills add github/awesome-copilot --skill react18-enzyme-to-rtl
Source repository · Upstream listing
React 18 Enzyme → RTL Migration
Enzyme has no React 18 adapter and no React 18 support path. All Enzyme tests must be rewritten using React Testing Library.
The Philosophy Shift (Read This First)
Enzyme tests implementation. RTL tests behavior.
This is not a 1:1 translation. Enzyme tests that verify internal state or instance methods don't have RTL equivalents because RTL intentionally doesn't expose internals. Rewrite the test to assert the visible outcome instead.
API Map
For complete before/after code for each Enzyme API, read:
references/enzyme api map.md full mapping: shallow, mount, find, simulate, prop, state, instance, configure
references/async patterns.md waitFor, findBy, act(), Apollo MockedProvider, loading states, error states
Core Rewrite Template
RTL Query Priority (use in this order)
1. getByRole matches accessible roles (button, textbox, heading, checkbox, etc.)
2. getByLabelText form fields linked to labels
3. getByPlaceholderText input placeholders
4. getByText visible text content
5. getByDisplayValue current value of input/select/textarea
6. getByAltText image alt text
7. getByTitle title attribute
8. getByTestId data testid attribute (last resort)
Prefer getByRole over getByTestId . It tests accessibility too.
Wrapping with Providers