Testable React Components
summary
Concrete rules for making React components testable: separate concerns so AJAX lives in a thin fetch component and UI is props driven not state driven, mock network/auth during unit tests, and render with TestUtils using scry vs find and call getDOMNode before DOM APIs. Tests use TestUtils.simulate for events and Karma with coverage reporting shows per-line hits and color thresholds. Common failures include missing props, multiple inputs breaking find, and getAttribute errors when interacting with non-DOM nodes.
AI-written summary · about
chapters (6)
related talks
53mTesting React Applications
28mTesting React Components
01h 00mTest Driving React Applications
10mTesting React Applications
30mTesting React Applications
47mREACTive Automation: How to Avoid Shooting Yourself in the Foot
24mUsing React Testing Library to Write Stronger Tests
19mImportance of testing & the right way to test React components
