Skip to content

Latest commit

 

History

History
17 lines (10 loc) · 490 Bytes

what_are_mocks_in_jest_.md

File metadata and controls

17 lines (10 loc) · 490 Bytes

What are mocks in Jest?

Mocks in Jest are used to simulate the behavior of real objects or functions. They are useful for isolating tests and avoiding dependencies on external systems, such as APIs or databases.

Example:

const myFunction = jest.fn();
myFunction.mockReturnValue(10);
expect(myFunction()).toBe(10);

Tags: intermediate, Jest, Mocks