Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Mocking Strategies?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ansh44233-mocking-strategies)
---
description: Mock at the right boundary: fakes for owned interfaces, network-level stubs for HTTP, and real dependencies where cheap
profile: standard
tags: testing, mocking, test-doubles
---
# Mocking strategies
Over-mocking produces tests that pass while production breaks.
## Where to mock
- Mock what you don't own at the network boundary (MSW, nock, responses, WireMock), not deep inside libraries.
- Use in-memory fakes for your own interfaces (repositories, clocks, queues).
- Use real dependencies when they're fast and deterministic (SQLite is not Postgres; prefer Testcontainers for DB behavior).
## Rules
- Assert on outcomes, not on call counts, unless the call is the behavior (sending an email).
- Inject time, randomness and IDs so tests are deterministic.
- Keep mocks consistent with real responses (record them, or validate against the API schema).
## Verify
Temporarily break the real integration in a way the mock wouldn't notice and check whether a contract or integration test catches it.