# Test Mocking Rules

> Guidelines for when and how to use mocks in tests

- Skill: `snoodleboot-io/test-mocking-rules-2` (Agent Skill)
- Install (CLI): `npx get-skill add snoodleboot-io/test-mocking-rules-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/snoodleboot-io/test-mocking-rules-2/raw
- Safety review: pending (external: skill-scanner PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: snoodleboot-io (https://skillmd.com/u/snoodleboot-io)
- Updated: 2026-11-15
- Page: https://skillmd.com/skills/snoodleboot-io/test-mocking-rules-2

---


## Mocking Rules

### When to Mock
- Mock only at process boundaries:
  - Database connections
  - Network calls (HTTP, external APIs)
  - Filesystem operations
  - Time/date functions
  - Random number generation

### What NOT to Mock
- **Never mock the thing under test**
- **Never mock internal helpers** — test them through the public interface
- **Never mock your own database** in integration tests

### Consistency
- Use the mock library from core-conventions.md consistently
- Follow the same mocking patterns across the codebase

