Pick the fix
How should you test a view model that debounces search input by 300 ms?
Hint 1 of 1
Who controls time in the test?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Inject a test scheduler, send input, advance time by 300 ms and assert the request
Correct. It's deterministic and instant.
Why not the others?
- B Send input, call sleep(1), then assert. Slow and flaky on busy CI machines.
- C Only check that the pipeline compiles. It doesn't test behaviour.
- D Assert immediately after sending input. The debounced value hasn't been emitted yet.