enzyme-to-rtl

Installation
SKILL.md

Enzyme to React Testing Library Migration

Goal

Migrate enzyme tests to @testing-library/react as a 1:1 port — preserve existing test intent without refactoring toward integration-style testing or removing mocks.

Core principles

  • Preserve test intent. Do not rewrite test logic or remove mocks. Add mocks where enzyme's shallow rendering previously hid missing providers/contexts.
  • Cut dead tests. Enzyme tests component trees, not DOM. Tests that assert on elements never actually rendered in the DOM should be removed with a comment explaining why.
  • No new data-test-subj for snapshots. Use container.children[0] for root-element snapshots instead of adding a test locator just for snapshotting.

Migration workflow

  1. Replace enzyme imports with RTL imports.
  2. Replace shallow() / mount() with render().
  3. Migrate selectors and assertions.
  4. Update or delete snapshots (--updateSnapshot).
  5. Run the test and fix any missing mocks/providers that enzyme's shallow rendering was hiding.
Related skills
Installs
1
Repository
elastic/kibana
GitHub Stars
21.1K
First Seen
4 days ago