github avatar

React18 Enzyme To Rtl

If you're stuck migrating Enzyme tests to React Testing Library for a React 18 upgrade, this walks you through the entire API mapping and the bigger conceptual shift from implementation testing to behavior testing. It's not about translating wrapper.find() or wrapper.state() one to one, it's about rewriting tests to assert what users actually see instead of poking at component internals. You get concrete before and after examples for shallow, mount, simulate, and all the tricky async patterns with Apollo and loading states. The query priority guide alone will save you from littering tests with data-testid attributes. Covers the philosophy enough that you won't just produce brittle RTL code that still thinks like Enzyme.

skills.sh installs
742
GitHub stars
41K
last updated
Aug 21, 2026

Install

$ npx -y skills add github/awesome-copilot --skill react18-enzyme-to-rtl --agent claude-code

Installs into .claude/skills of the current project.

Files

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.

// Enzyme: tests that the component has the right internal state
expect(wrapper.state('count')).toBe(3);
expect(wrapper.instance().handleClick).toBeDefined();
expect(wrapper.find('Button').prop('disabled')).toBe(true);

// RTL: tests what the user actually sees and can do
expect(screen.getByText('Count: 3')).toBeInTheDocument();
expect(screen.getByRole('button', { name: /submit/i })).toBeDisabled();

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

Sponsors

Details

Repository
github.com/github/awesome-copilot
Categories
Frontend Development, Backend & APIs, Testing & QA, Git & Pull Requests, AI & Agent Building
First seen
May 16, 2026

More from github/awesome-copilot

All 318
1mindrally avatarpostcss-best-practicesmindrally/skillsPostCSS best practices and configuration guidelines for modern CSS processing and optimization738skills.sh installs
2mindrally avatarvercel-developmentmindrally/skillsVercel and Next.js deployment best practices including server components, edge functions, AI SDK integration, and performance optimization.738skills.sh installs
3mrgoonie avataraestheticmrgoonie/claudekit-skillsCreate aesthetically beautiful interfaces following proven design principles. Use when building UI/UX, analyzing designs from inspiration sites, generating desi722skills.sh installs
4mindrally avatarless-best-practicesmindrally/skillsLess CSS best practices and coding guidelines for maintainable, modular stylesheets717skills.sh installs
5glitternetwork avatarpinmeglitternetwork/pinmeUse this skill when the user mentions "pinme", or needs to upload files, store to IPFS, create/publish/deploy websites or full-stack services (including fronten715skills.sh installs
6langgenius avatarorpc-contract-firstlanggenius/difyGuide for implementing oRPC contract-first API patterns in Dify frontend. Trigger when creating or updating contracts in web/contract, wiring router composition713skills.sh installs