Testing · Senior · Question 37 of 75
How do you test a component inside an error boundary without noisy logs?
- ✓Correct answer: Render a child that throws, assert the fallback UI, and spy on
console.errorwith an empty implementation for that test - 2Disable all console output globally
- 3Error boundaries can't be tested
Explanation
Restore the spy afterwards so unexpected errors in other tests stay visible.