Using React Testing Library to Write Stronger Tests
summary
Argues that switching from enzyme to react-testing-library stops brittle, white‑box tests and forces tests to exercise only the render output and DOM interactions; demos using fireEvent, getByLabelText and getByTitle, plus the toHaveStyle matcher to assert theme colors. Shows testing hooks, controlled vs uncontrolled components, redux and i18n providers, and a persisted theme that survives unmount/rerender by recreating the store. Notes a prior 100% coverage suite that constantly broke and how the new approach fixes that.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 0:35My history of tests
- 1:53Controlling vs Uncontrolled Components
- 4:47React Testing Library
- 5:36What is React Testing
- 6:07What React Testing Library Encourages
- 9:06Real World Example
- 10:17User Representation
- 14:12RealWorld Example
related talks
25mTesting React
22mElizabeth Funk - An Introduction to React Testing Library
30mTesting Front-End Applications
18mTesting React in a Right Way
53mTesting React Applications
30mTesting Library: everybody uses it, but nobody understands it
39mReact Hooks broke my tests, now what?
32mEstablishing testing patterns with software design principles
