mock-best-practices
What it does
This skill reviews how a test file uses mocks, which are stand-ins for outside parts of the code. It is for developers who want tests that catch real problems rather than only passing.
When to use it
- ✓When you ask the agent to review how a test file uses mocks.
- ✓When tests pass but the real app breaks, and you suspect too much is being mocked.
- ✓When you are writing new tests and want guidance on what to mock and what to leave real.
Skill link
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/mock-best-practices/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“My tests pass but the app still breaks. Can you check whether I am mocking too much?”
5 new skills a week. 1 minute to read.
How it works
The agent reads the test file and looks for mocks that hide business logic, missing cleanup, and tests that check internal details. It then suggests removing unnecessary mocks and mocking at the right level.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
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
FAQ
What should be mocked?
The skill says to mock external dependencies such as APIs, databases, and the file system, not business logic.
What is MSW?
It is a tool for realistic API mocking that does not depend on how your code calls the API.
Why clean up mocks?
Mocks left in place between tests can change results and make failures hard to understand.
Details
Original description by the author
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.
Popularity
- GitHub stars
- 75k
- Ranking position
- #2941
- License
- MIT
- Updated
- 10/31/2026
Comments
- …
More skills from this repository
frontendchecklist
75kChecks frontend code and live pages against 380+ rules for accessibility, speed, SEO and security, using a command-line tool.
frontend-checklist-global
75kAudits a frontend project against all 386 Front-End Checklist rules, and gives a specific fix for each issue found.
404-page
75kChecks that your missing-page screen offers helpful links and returns a real 404 status, to help lost visitors find their way.
about-page
75kReviews whether your site has a clear About page that explains who runs it, to build trust with visitors and search engines.
Similar skills
test-driven-development
311kTeaches your agent to write a failing test first, watch it fail, then write the smallest code that passes, before building any feature or fix.
verification-before-completion
311kTeaches your agent to run real checks and read their output before claiming that a task, fix, or build is complete or passing.
migrate-to-shoehorn
310kReplaces risky type casts in your test files with the shoehorn library, so tests can use partial data and still pass type checks.