Skip to main content
skill GitHub Copilot official · GitHub

react18-enzyme-to-rtl — GitHub Copilot skill: what it does

Provides Enzyme to React Testing Library migration patterns for React 18 upgrades. Useful when rewriting shallow renders, mount calls, and state assertions into user behavior checks.

Install into GitHub Copilot · Skills CLI (Vercel) All methods and platforms ↓
npx skills add github/awesome-copilot --skill react18-enzyme-to-rtl
Open on GitHub

What react18-enzyme-to-rtl does

Enzyme lacks an adapter for React 18, which breaks test suites during framework upgrades. This skill guides the assistant to convert Enzyme suites to React Testing Library rather than attempting a literal translation. Direct checks on wrapper.state() or instance() methods are swapped for visible screen assertions.

The skill outlines standard rewrite templates, event handling with userEvent, and context provider wrappers like Apollo MockedProvider or ThemeProvider. It also enforces a query priority, placing accessible queries like getByRole and getByLabelText ahead of getByTestId.

Install this if your codebase still relies on Enzyme and needs React 18 compatibility. Without these patterns, assistants tend to generate brittle RTL tests that still search for internal component properties.

What it helps with

  • Rewrite legacy Enzyme test suites for React 18 compatibility
  • Replace shallow, mount, and simulate with render and userEvent
  • Convert internal state checks into assertions on visible DOM output
  • Prioritize accessible queries like getByRole over brittle getByTestId

Example prompts for the agent

  • Rewrite this Enzyme test file to React Testing Library for React 18
  • Convert wrapper.find and simulate clicks in Button.test.jsx to userEvent
  • Wrap this component test in MockedProvider and ThemeProvider using RTL patterns

How to install react18-enzyme-to-rtl

1Skills CLI (Vercel)

npx skills add github/awesome-copilot --skill react18-enzyme-to-rtl

2GitHub CLI

gh skill install github/awesome-copilot react18-enzyme-to-rtl

3Manually: put the files in place

.github/skills/react18-enzyme-to-rtl/SKILL.md

From the same set554

The whole set →
git-commit official github This skill reviews Git changes, stages related files, and creates Conventional Commits. Use it when you want an agent to make one commit or split work into separate commits. GitHub Copilot 47,165installs excalidraw-diagram-generator official github Turn a plain-language description into an Excalidraw diagram. Useful for mapping processes, system structure, and relationships between entities. GitHub Copilot 31,639installs multi-stage-dockerfile official github This skill guides GitHub Copilot in writing multi-stage Dockerfiles for different languages and frameworks. Use it when the final runtime image should contain fewer build dependencies. GitHub Copilot 29,688installs documentation-writer official github Skill that turns the agent into a technical writer following the Diátaxis framework: tutorials, how-to guides, reference, and explanation. Proposes structure before writing. GitHub Copilot 27,757installs prd official github Turns a feature idea into a structured PRD with user stories, technical requirements, and risks. Use it when planning a software feature or an AI-powered one. GitHub Copilot 24,035installs refactor official github This skill reshapes existing code without changing its external behavior. Use it for gradual cleanup of large functions, duplication, weak types, and code smells. GitHub Copilot 22,321installs java-springboot official github Gives GitHub Copilot Spring Boot development practices, from project layout to tests and security. Use it when writing or reviewing Java application code. GitHub Copilot 21,272installs create-readme official github This skill reviews a project and creates a structured README.md. Use it when the repository needs clear documentation based on its actual files and code. GitHub Copilot 19,081installs

Similar

engineering-skills Alireza Rezvani An engineering skill index for Claude Code that helps you select one specialist SKILL.md for the task at hand. It covers architecture, testing, DevOps, and data work. Claude Code 2,387installs senior-frontend Alireza Rezvani Scaffolds Next.js and React projects, generates components with tests, and audits bundle size to replace heavy dependencies. Claude Code 1,630installs generate Alireza Rezvani The generate skill writes Playwright tests from a user story, URL, component name or feature description. Useful when an e2e scenario needs covering and you would rather not hand-write it. Claude Code 1,624installs frontend-design official anthropics This skill guides intentional visual design for new interfaces and redesigns. Use it when a generic generated UI is not enough. Claude Code Claude.ai 1,025,790installs design-taste-frontend Leonxlnx This skill directs the design of public pages and work screens, then checks the result in a browser through screenshots. Use it when an interface feels generic or unfinished. Claude Code CX Codex Cursor +1 673,100installs prototype Matt Pocock Creates throwaway prototypes for checking state logic or exploring UI before committing the decision to the main codebase. Claude Code 986,201installs hyperframes heygen-com Instructs coding agents on creating, validating, and rendering HTML-based videos using the HyperFrames framework and CLI. Claude Code CX Codex Cursor +1 1,200,000installs hyperframes-cli heygen-com Controls HyperFrames video workflows from the CLI: audits layouts and contrast, edits timeline clips, captures snapshots, and renders locally or in cloud runtimes. Claude Code CX Codex Cursor +1 1,200,000installs

Questions about react18-enzyme-to-rtl

How to install react18-enzyme-to-rtl in GitHub Copilot?

Run gh skill install github/awesome-copilot react18-enzyme-to-rtl or npx skills add github/awesome-copilot --skill react18-enzyme-to-rtl.

What does react18-enzyme-to-rtl do?

It teaches GitHub Copilot how to migrate legacy Enzyme tests to React Testing Library. It replaces implementation checks with user-facing assertions needed for React 18.

Why avoid a 1:1 API translation from Enzyme to RTL?

React Testing Library deliberately conceals component state and internal instances. Direct translations produce brittle tests, so assertions must target what users actually see.

Source text

SKILL.md · MIT
---
name: react18-enzyme-to-rtl
description: '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 file that imports from enzyme. This skill covers the full API mapping and the philosophy shift from implementation testing to behavior testing. Always read this skill before rewriting Enzyme tests - do not translate Enzyme APIs 1:1, that produces brittle RTL tests.'
---

# 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.

```jsx
// 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

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

```jsx
// Every Enzyme test rewrites to this shape:
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import MyComponent from './MyComponent';

describe('MyComponent', () => {
  it('does the thing', async () => {
    // 1. Render (replaces shallow/mount)
    render(<MyComponent prop="value" />);

    // 2. Query (replaces wrapper.find())
    const button = screen.getByRole('button', { name: /submit/i });

    // 3. Interact (replaces simulate())
    await userEvent.setup().click(button);

    // 4. Assert on visible output (replaces wrapper.state() / wrapper.prop())
    expect(screen.getByText('Submitted!')).toBeInTheDocument();
  });
});
```

## 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

```jsx
// Enzyme with context:
const wrapper = mount(
  <ApolloProvider client={client}>
    <ThemeProvider theme={theme}>
      <MyComponent />
    </ThemeProvider>
  </ApolloProvider>
);

// RTL equivalent (use your project's customRender or wrap inline):
import { render } from '@testing-library/react';
render(
  <MockedProvider mocks={mocks} addTypename={false}>
    <ThemeProvider theme={theme}>
      <MyComponent />
    </ThemeProvider>
  </MockedProvider>
);
// Or use the project's customRender helper if it wraps providers
```

© github · MIT · github/awesome-copilot

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor