Skip to content
Testing·Intermediate·Conceptual·1 min read

What's wrong with asserting after a fixed setTimeout(resolve, 500) in a test?

Short interview answer

It's both slow and unreliable — too short and it flakes under CI load, too long and it wastes time on every run. Waiting for an actual observable condition adapts to real timing instead of guessing a number.

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to Mocking, test doubles, and async tests

Related questions