~/talk

React Hooks broke my tests, now what?

Talkat CityJS London 2023 · 2023-04-21..04-23· [react, testing]
slides:none on file

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

  1. 0:00Introduction and speaker intro
  2. 2:58React Hooks broke my tests
  3. 10:02Testing Library fundamentals
  4. 18:44Querying strategies explained
  5. 22:34Common Testing Library mistakes
  6. 26:25Fixing act() and async issues
  7. 28:57Conclusion and key takeaways
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.