Question 5 of 10Pro Only

What is mocking in testing? How do you mock functions, modules, and API calls in Jest?

Sample answer preview

## What is Mocking? Mocking is **replacing real implementations with controlled fake versions** to: - Isolate the code under test - Control external dependencies - Make tests faster and deterministic - Avoid side effects (API calls, database writes) ## Mock Functions (jest.fn)…

mockingjest.fnjest.mockspyOnMSWfetch mock

Unlock the full answer

Get the complete model answer, key points, common pitfalls, and access to 9+ more Full-Stack Developer interview questions.

Upgrade to Pro

Starting at $19/month • Cancel anytime