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

Why should mocks be reset between tests?

Short interview answer

A mock's configured return value or call history can leak into the next test if not reset, causing one test's setup to silently affect another test's assertions and producing failures that only appear depending on run order.

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