.cursor/skills/mocking/SKILL.md
When and how to mock (system boundaries only, DI, SDK-style APIs). Use when writing tests, reviewing mocks, or the user asks what to mock.
npx skillsauth add jorgsouza/QAFeedback mockingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Mock at system boundaries only:
Don't mock:
At system boundaries, design interfaces that are easy to mock:
1. Use dependency injection
Pass external dependencies in rather than creating them internally:
// Easy to mock
function processPayment(order, paymentClient) {
return paymentClient.charge(order.total);
}
// Hard to mock
function processPayment(order) {
const client = new StripeClient(process.env.STRIPE_KEY);
return client.charge(order.total);
}
2. Prefer SDK-style interfaces over generic fetchers
Create specific functions for each external operation instead of one generic function with conditional logic:
// GOOD: Each function is independently mockable
const api = {
getUser: (id) => fetch(`/users/${id}`),
getOrders: (userId) => fetch(`/users/${userId}/orders`),
createOrder: (data) => fetch('/orders', { method: 'POST', body: data }),
};
// BAD: Mocking requires conditional logic inside the mock
const api = {
fetch: (endpoint, options) => fetch(endpoint, options),
};
The SDK approach means:
development
Good vs bad tests (integration-style, public API, behavior not implementation). Use when writing or reviewing tests, or paired with TDD and mocking skills.
development
Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.
development
Refactor candidates after TDD (duplication, long methods, shallow modules, etc.). Use during refactor phase of red-green-refactor or when reviewing code quality.
tools
Turn a PRD into a multi-phase implementation plan using tracer-bullet vertical slices, saved under ./prd/PRD-NNN-feature-slug/plan.md (see prd/INDEX.md). Use when user wants to break down a PRD, create an implementation plan, plan phases from a PRD, or mentions "tracer bullets".