New: Cookbooks and AI ExplanationsStep-by-Step recipes to solve problems connected to Roadmaps and Cheat Sheets. Need more details? Use AI buttons for structured and simple explanations with concrete examples throughout the whole platform.Take a look
My debounced search box waits 400ms before it fires. Testing it for real means every run of the suite sits there waiting.
What you'll have at the end
The debounce test passing in milliseconds, using fake timers instead of a real wait
You need
A component test file that already renders a debounced input with Testing Library, where the component's own effect calls setTimeout once per change, clears it in its cleanup function, and calls an async function once the delay passes.
Not covered
A throttled handler that fires repeatedly at a fixed rate while the user keeps typing, instead of once after they stop; that needs a running call count checked at each interval, not one trailing assertion.
Leans on
Checked 25 Aug 2026
Part of the Vitest Testing Framework cookbook