Skip to content
Back to skills

Mocking Strategies

ASecurity

Mock at the right boundary: fakes for owned interfaces, network-level stubs for HTTP, and real dependencies where cheap

  • 7 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 30, 2026
ai-agentssqltestingapi

Works with

  • api

Security analysis

A100/100

Scanned November 30, 2026

npx -y skills add ansh44233/forge --skill mocking-strategies --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mocking Strategies?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Mocking Strategies
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ansh44233-mocking-strategies/badge)](https://www.skillsdirectory.com/skills/ansh44233-mocking-strategies)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.