React Hooks broke my tests, now what?
summary
Migrating class components to Hooks causes more than half the tests to fail because tests inspect implementation details (state, props, shallow rendering) rather than user-visible behavior. Replace Enzyme shallow tests with React Testing Library patterns: prefer accessible queries (getBy/queryBy/findBy), use user-event for realistic interactions, and use waitFor/findBy or assert loading indicators to satisfy React’s act. Use the testing playground to pick queries, avoid overusing test IDs or container.querySelector, and assert visible output not internals.
AI-written summary · about
