Purpose of Mocks
Multiple Choice Medium
Question
Why would you use a mock in a unit test?
Hint
Mocks stand in for real things you don't want to use.
Explanation
Mocks replace real dependencies (like database calls, network requests, or external services) with controllable fake versions. This keeps unit tests fast, deterministic, and isolated — you test only the unit's logic without depending on external systems.
Related Resources
Related Lessons
- Mocking
Using mocks to isolate code.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.