This document discusses unit testing React user interfaces from an existential perspective. It recommends testing the happy path, component behavior, and edge cases, but not server logic, third party components, or things beyond the component's edges. Key points covered include using snapshots to test the happy path, simulating user input to test behavior, and mocking dependencies to test edge cases. The overall message is that unit tests should influence component design and help move non-testable code outside the component.
15. There¡¯s no recipe
¡°Ten or twenty years from now we'll likely
have a more universal theory of which tests to
write, which tests not to write, and how to tell
the difference. In the meantime,
experimentation seems in order.¡±
- Kent Beck, test coverage guy
Artist: Andrew Baines
43. A brand new test
// HAPPY PATH:
// component renders as we expect
// BEHAVIOR:
// what behavior does the component itself have?
// EDGE CASES:
// what failure cases should our component handle?
friendsList.test.js
64. Artists featured: Alexandra Levasseur,
Andrew Baines, Edvard Munch, Rene
Magritte, Rafal Olbinski, Salvador Dali
¡ñ React development & testing
¡ñ Existential questions
¡ñ Social Justice Fund
Thanks!
@bookstein
/donation-tracking