enzyme-to-rtl

Migrate Enzyme tests to React Testing Library by converting imports, renders, selectors, and assertions.

21.2k|8.6k|Updated Jan 26, 2013
One-click install
npx skills add https://github.com/elastic/kibana --skill enzyme-to-rtl
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: enzyme-to-rtl
Source: https://github.com/elastic/kibana/tree/main/.agents/skills/enzyme-to-rtl
Command: npx skills add https://github.com/elastic/kibana --skill enzyme-to-rtl

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill automates the migration of existing Enzyme tests to React Testing Library (RTL), ensuring test integrity while modernizing your testing framework.

Core Features & Use Cases

  • Automated Migration: Converts Enzyme imports, rendering methods (shallow/mount), and selectors to their RTL equivalents.
  • Assertion Conversion: Adapts Enzyme assertions to RTL's DOM-querying approach.
  • Snapshot Updates: Guides the regeneration of snapshot tests for the new testing paradigm.
  • Use Case: When refactoring a large React application, use this Skill to systematically update hundreds of Enzyme tests to RTL, reducing manual effort and potential errors.

Quick Start

Use the enzyme-to-rtl skill to migrate the test file '/path/to/your/enzyme/test.js'.

Frequently Asked Questions about enzyme-to-rtl

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate Enzyme tests to React Testing Library?

To migrate Enzyme tests to React Testing Library, you need to replace Enzyme imports, convert shallow or mount rendering methods to RTL render, and update DOM selectors. This process also involves adapting assertions and regenerating snapshot tests to ensure test intent preservation.

What is the best way to convert Enzyme shallow and mount renders to RTL?

Converting Enzyme shallow and mount renders to RTL involves replacing them with the RTL render method. This automated migration adapts your rendering approach to RTL's DOM-querying paradigm while ensuring the original test intent is preserved without requiring extensive refactoring.

How do I update snapshot tests when migrating from Enzyme to React Testing Library?

Updating snapshot tests during Enzyme to React Testing Library migration requires regenerating snapshots for the new testing paradigm. The migration process guides these snapshot updates alongside converting imports, render methods, and assertions to maintain test integrity.

Can I migrate Enzyme selectors to RTL queries without refactoring the entire test?

Yes, you can migrate Enzyme selectors to RTL queries without refactoring the entire test. The migration process targets replacing enzyme selectors with RTL queries and adapting assertions directly, ensuring test intent preservation without forcing a complete test refactoring.

Does migrating Enzyme tests to React Testing Library handle assertion conversion?

Migrating Enzyme tests to React Testing Library handles assertion conversion by adapting Enzyme assertions to RTL's DOM-querying approach. It systematically updates imports, render methods, selectors, and assertions to modernize your React testing framework.

Are there limitations when converting large React applications from Enzyme to RTL?

When converting large React applications from Enzyme to RTL, the primary consideration is ensuring test intent preservation without refactoring. While the migration automates import, selector, and assertion updates, complex snapshot tests may require guided regeneration to fit the new testing paradigm.