All jobs / Frontend / web developer / Testing

Frontend / web developer interview question · 1–3 years

How do you test a search box that debounces input by 300 ms, in Jest or Vitest, without slowing the suite down?

The strongest answer

Switch on fake timers, type, advance the clock by 300 ms, assert one call with the last term, then restore real timers afterwards so other tests are not affected

Why it works

Exactly — the test controls time, runs in milliseconds, and can also assert that nothing fired at 299 ms.

What a good answer covers

Answers that fall short

Who gets asked this

More Testing questions