Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
github avatar

React18 Enzyme To Rtl

  • 744 installs
  • 37.1k repo stars
  • Updated July 28, 2026
  • github/awesome-copilot

react18-enzyme-to-rtl rewrites Enzyme tests to React Testing Library with behavior-first assertions for React 18.

About

React 18 Enzyme to RTL Migration states Enzyme has no React 18 adapter and requires full rewrites using React Testing Library instead of one-to-one API translation. The philosophy shift moves from implementation tests on wrapper.state, wrapper.instance, and wrapper.prop to user-visible outcomes via screen queries and userEvent interactions. An API map in references/enzyme-api-map.md covers shallow, mount, find, simulate, prop, state, instance, and configure mappings plus async patterns with waitFor and MockedProvider. The core rewrite template uses render, getByRole queries, userEvent clicks, and assertions on visible text. RTL query priority ranks getByRole first for accessibility-aligned tests and reserves getByTestId as last resort.

  • Enzyme has no React 18 adapter; all tests must be rewritten in RTL.
  • Philosophy shift: behavior and visible output, not internal state or instances.
  • Not a 1:1 API map; rewrite tests to assert what users see and do.
  • Core template: render, screen query, userEvent, visible assertion.
  • Query priority favors getByRole; getByTestId is last resort.

React18 Enzyme To Rtl by the numbers

  • 744 all-time installs (skills.sh)
  • +17 installs in the week ending Jul 17, 2026 (Skillselion tracking)
  • Ranked #567 of 2,184 Testing & QA skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
At a glance

react18-enzyme-to-rtl capabilities & compatibility

Capabilities
enzyme to rtl philosophy and non 1:1 rewrite gui · core render query interact assert template · rtl query priority ladder from getbyrole to getb · provider wrapping pattern for apollo and theme c · async patterns with waitfor, findby, and mockedp
Use cases
testing · refactoring
From the docs

What react18-enzyme-to-rtl says it does

Enzyme has no React 18 adapter and no React 18 support path.
SKILL.md
This is not a 1:1 translation.
SKILL.md
npx skills add https://github.com/github/awesome-copilot --skill react18-enzyme-to-rtl

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs744
repo stars37.1k
Security audit3 / 3 scanners passed
Last updatedJuly 28, 2026
Repositorygithub/awesome-copilot

How do I replace Enzyme shallow, mount, and wrapper APIs now that Enzyme lacks React 18 support?

Rewrite Enzyme shallow and mount tests to React Testing Library with behavior-first assertions during React 18 upgrades.

Who is it for?

Frontend teams with Enzyme test suites blocking React 18 upgrades.

Skip if: Skip for greenfield RTL projects, production component code migration, or dependency version matrices.

When should I use this skill?

Test files import enzyme, use shallow/mount, wrapper.find, simulate, state, prop, or instance APIs.

What you get

RTL rewrite template, query priority guide, provider wrapping patterns, and async reference mappings.

  • RTL test files
  • behavior-first test queries

By the numbers

  • Covers 8 Enzyme API areas: shallow, mount, find, simulate, prop, state, instance, and Adapter config

Files

SKILL.mdMarkdownGitHub ↗

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

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

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

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

Related skills

How it compares

Pick react18-enzyme-to-rtl over generic RTL tutorials when migrating existing Enzyme suites that use wrapper internals on a React 18 upgrade.

FAQ

Can I translate Enzyme APIs 1:1 to RTL?

No. RTL intentionally hides internals; rewrite tests to assert visible user outcomes instead.

What replaces wrapper.simulate click?

Use userEvent.setup().click on a screen query result from getByRole or similar.

How test wrapper.state count?

Assert visible text like screen.getByText('Count: 3') instead of reading component state.

Is React18 Enzyme To Rtl safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Testing & QAtestingfrontend

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.