Search⌘ K
AI Features

Mock Functions

Discover how to use Jest mock functions including jest.fn() and jest.spyOn() to simulate external dependencies, control function calls and return values, and assert interactions in your tests. This lesson helps you isolate code, test error scenarios, and validate function usage without relying on actual implementations.

Why do we mock functions?

There are three main reasons that we mock ...