What did React Testing Library replace?
It replaced Enzyme, which tested components by their internal implementation like instance methods, state, and child component structure. Enzyme tests were coupled to implementation and broke on refactors. RTL tests behavior instead.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in What Is React Testing Library and Why It Changed React Testing
RTL is a library for testing React components by interacting with them the way a user would: rendering them, finding elements by role or visible text, and simulating user events. It tests behavior, not implementation details.
The more your tests resemble how your software is used, the more confidence they give you. RTL tests what the user sees and does, not how the component is implemented internally, so tests survive refactors.
Because these are the same queries screen readers use, so your tests double as accessibility checks. Testing by role and visible text also focuses on what the user experiences, not on implementation details like class names or test ids.
Still have questions?
Browse all our FAQs or reach out to our support team
