thedaviddias/Front-End-Checklist / skills/mock-best-practices
mock-best-practices
VerifiedUse when reviewing CI coverage, automated checks, or test strategy related to Follow mocking best practices. Focus on whether the rule is continuously verified, not just documented.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 1.7 KB |
| references/rule.md | markdown | 3.9 KB |
SKILL.md
View on GitHub---
name: mock-best-practices
description: "Use when reviewing CI coverage, automated checks, or test strategy related to Follow mocking best practices. Focus on whether the rule is continuously verified, not just documented."
metadata:
category: testing
priority: medium
difficulty: intermediate
estimatedTime: "20"
source: frontendchecklist.io
url: https://frontendchecklist.io/rules/testing/mock-best-practices
---
# Follow mocking best practices
Proper mocking isolates units under test while keeping tests realistic—over-mocking creates false confidence when tests pass but production breaks.
## Quick Reference
- Mock external dependencies (APIs, databases, file system), not business logic
- Always clean up mocks with jest.restoreAllMocks() in afterEach
- Use MSW for realistic API mocking without coupling to implementation
- Test behavior and outputs, not internal implementation details
## Check
Review this test file for mocking patterns, checking for over-mocking, missing mock cleanup, and proper mock implementation.
## Fix
Improve mocking strategy by removing unnecessary mocks, adding proper cleanup, and mocking at the right level of abstraction.
## Explain
Explain mocking best practices including when to mock, what to mock, and common mocking pitfalls.
## Code Review
Review tests, CI workflows, and enforcement points related to Follow mocking best practices. Flag exact gaps where the rule is not automatically verified or where failures do not block regressions.
---
For full implementation details, code examples, and framework-specific guidance,
see `references/rule.md`.
Rule page: https://frontendchecklist.io/rules/testing/mock-best-practices
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |