Testing · Middle · Question 7 of 75
How do you test a debounced search input?
- ✓Correct answer: Use fake timers, type, advance time by the debounce delay and check the request/result
- 2Add
await new Promise(r => setTimeout(r, 500))to the test - 3Remove the debounce in tests with an environment flag
Explanation
Fake timers make the test fast and deterministic. Real waits slow the suite and still race.