A type of test double that records how many times it was called and with what arguments, letting you verify it was used as expected.
Unlike a stub, which simply returns a fixed value, a mock is used to make behavioral assertions such as "this function should have been called exactly once, with these arguments." Many testing frameworks, such as Jest and Mockito, include built-in mocking support.
© 2026 ITBGM