testing-strategy
Skill8 starsChanged 2 months agoMITView on GitHub
Testing approach covering unit/integration/e2e split, what to test, AAA test structure, mocking strategies, and coverage targets. Use when writing tests, planning test coverage, or reviewing test quality.
- Reads credentials
54 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- jDxve/avengers-kittheir own version, first seen Nov 8, 2026
- nisarth/claude-skills-storetheir own version, first seen Nov 8, 2026
- ccoalm/ccl-skillstheir own version, first seen Nov 8, 2026
- komluk/scaffoldingtheir own version, first seen Nov 7, 2026
- bmsuisse/skillstheir own version, first seen Nov 6, 2026
- Cure-Consulting-Group/ProductEngineeringSkillstheir own version, first seen Nov 4, 2026
Used with
Projects with it also use api-contract-design, deploy-checklist and 8 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
MohOneXSkillapi-contract-design
Designs and reviews API contracts (REST, RPC, GraphQL, library interfaces) for evolvability, backward compatibility, and failure semantics. Use when defining new endpoints/interfaces, versioning an API, reviewing a schema, or deciding how breaking changes propagate to clients.
Also in 3 projects that use this
AnthropicSkilldeploy-checklist
Pre-deployment verification checklist. Use when about to ship a release, deploying a change with database migrations or feature flags, verifying CI status and approvals before going to production, or documenting rollback triggers ahead of time.
Also in 4 projects that use this
AnthropicSkilltech-debt
Identify, categorize, and prioritize technical debt. Trigger with "tech debt", "technical debt audit", "what should we refactor", "code health", or when the user asks about code quality, refactoring priorities, or maintenance backlog.
Also in 4 projects that use this
MicrosoftSkillerror-handling
统一错误处理系统。在添加 API 端点、修改错误处理、添加前端 API 调用、编写错误相关测试时使用。
Also in 5 projects that use this
Microsoft AzureSkillrelease-readiness
Complete ODIN release documentation and validation checks before declaring user-visible work complete, preparing a release, or opening the Release-to-main pull request.
Also in 3 projects that use this
MicrosoftSkilldeep-review
Multi-agent deep code review for regorus. Three diverse parallel discovery agents with context asymmetry, risk-triggered micro-passes, adversarial gap-finder, and verification with disproval mandates. Use for high-stakes changes.
Also in 3 projects that use this
- +4 more from anthropics
Other versions54 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- halflength-ampleness75/claude-code-recipes★ 2100% same
Wrote their own version · 53
- anthropics/knowledge-work-plugins★ 35ksame name
- chthollyphile/folia-major★ 12ksame name
- Community-Access/accessibility-agents★ 409same name
- AnastasiyaW/claude-code-config★ 214same name
- AnastasiyaW/codex-claude-code-config★ 214same name
- irahardianto/awesome-agv★ 157same name
- Blushyes/reef★ 84same name
- shinpr/agentic-code★ 51same name
- addxai/enterprise-harness-engineering★ 44same name
- drafthq/draft★ 40same name
43 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository5 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- api-designSkill
- git-workflowSkill
- react-patternsSkill
- typescript-strictSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 44 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Follow the testing pyramid -- more unit tests, fewer integration tests, even fewer e2e tests:
- Distinctive: line 53
Every test should follow Arrange, Act, Assert:
- Distinctive: line 106
Prefer lighter mocking techniques when possible:
“Common” is measured: kept by at least 6 in 10 of the 44 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Testing Strategy
Testing approach: unit/integration/e2e split, what to test, test structure (AAA pattern), mocking strategies, and coverage targets.
Testing Pyramid
Follow the testing pyramid -- more unit tests, fewer integration tests, even fewer e2e tests:
/ E2E \ ~5% -- Critical user journeys
/----------\
/ Integration \ ~20% -- Module boundaries, API contracts
/----------------\
/ Unit Tests \ ~75% -- Functions, components, utilities
/____________________\| Level | Speed | Scope | Quantity |
| Unit | Fast (ms) | Single function/component | Many |
| Integration | Medium (seconds) | Module interactions, DB, API | Some |
| E2E | Slow (seconds-minutes) | Full user flows | Few |
What to Test
Always Test
- Business logic and calculations
- Data transformations and mappings
- Validation rules
- Error handling paths
- Edge cases: empty inputs, boundary values, null/undefined
- Public API of modules (exported functions)
- State transitions (reducers, state machines)
- Critical user journeys (e2e)
Don't Test
- Third-party library internals
- Simple getters/setters with no logic
- Framework boilerplate (constructor, lifecycle method existence)
- Implementation details (private methods, internal state shape)
- Constants and configuration values
- CSS styling (use visual regression tools instead)
Test Structure -- AAA Pattern
Every test should follow Arrange, Act, Assert:
describe("OrderService", () => {
describe("calculateTotal", () => {
it("applies percentage discount to subtotal", () => {
// Arrange
const items = [
{ name: "Widget", price: 25.00, quantity: 2 },
{ name: "Gadget", price: 15.00, quantity: 1 },
];
const discount = { type: "percentage", value: 10 };
// Act
const total = calculateTotal(items, discount);
// Assert
expect(total).toBe(58.50); // (50 + 15) * 0.90
});
});
});Naming Rules
- Describe blocks name the unit --
describe("OrderService"),describe("calculateTotal") - Test names describe the behavior --
it("applies percentage discount to subtotal") - Use the pattern:
it("<expected behavior> when <condition>") - Don't start with "should" --
it("returns null for invalid input")notit("should return null...")
Structure Rules
- One assertion per test (conceptual, not literal -- multiple
expectcalls are fine if testing one behavior) - No logic in tests -- no
if,for, orswitchin test code - No test interdependencies -- each test sets up and tears down its own state
- Use
beforeEachfor shared setup, notbeforeAll-- isolation matters more than speed - Group related tests with nested
describeblocks
Mocking Strategies
When to Mock
| Mock | Don't Mock |
| External APIs and services | The unit under test |
| Database calls (in unit tests) | Simple utility functions |
| File system access | Data transformations |
| Timers and dates | Pure functions |
| Network requests | Collaborators (in integration tests) |
| Third-party services | Standard library methods |
Mocking Hierarchy
Prefer lighter mocking techniques when possible:
- Stubs -- return a fixed value:
jest.fn().mockReturnValue(42) - Spies -- observe calls without changing behavior:
jest.spyOn(service, 'save') - Fakes -- lightweight in-memory implementation:
new InMemoryUserRepository() - Mocks -- full behavior replacement:
jest.mock('./database')
Rules
- Mock at the boundary -- mock the database client, not the repository method
- Don't mock what you don't own -- wrap third-party APIs in your own adapter, mock the adapter
- Reset mocks between tests -- use
afterEach(() => jest.restoreAllMocks()) - Verify interactions sparingly -- prefer asserting on output over asserting mock was called
// Good -- mock at the boundary
const mockDb = { query: jest.fn().mockResolvedValue([{ id: 1, name: "Alice" }]) };
const repo = new UserRepository(mockDb);
const user = await repo.findById(1);
expect(user.name).toBe("Alice");
// Bad -- mocking the unit under test
jest.spyOn(repo, "findById").mockResolvedValue({ id: 1, name: "Alice" });Test Doubles for Common Scenarios
// Fixed time
beforeEach(() => {
jest.useFakeTimers();
jest.setSystemTime(new Date("2025-06-15T12:00:00Z"));
});
afterEach(() => jest.useRealTimers());
// API responses
const mockFetch = jest.fn().mockResolvedValue({
ok: true,
json: async () => ({ data: { id: 1 } }),
});
global.fetch = mockFetch;
// Environment variables
const originalEnv = process.env;
beforeEach(() => {
process.env = { ...originalEnv, API_KEY: "test-key" };
});
afterEach(() => {
process.env = originalEnv;
});Integration Tests
- Test module boundaries -- service calls repository, repository calls database
- Use a real (test) database -- SQLite in-memory or Docker containers
- Test API endpoints end-to-end -- use supertest or similar
- Seed data in
beforeEach-- don't rely on database state from other tests - Test error paths -- connection failures, timeouts, constraint violations
describe("POST /api/users", () => {
it("creates a user and returns 201", async () => {
const response = await request(app)
.post("/api/users")
.send({ email: "test@example.com", name: "Test User" })
.expect(201);
expect(response.body.data).toMatchObject({
email: "test@example.com",
name: "Test User",
});
expect(response.body.data.id).toBeDefined();
});
it("returns 400 for invalid email", async () => {
const response = await request(app)
.post("/api/users")
.send({ email: "not-an-email", name: "Test User" })
.expect(400);
expect(response.body.error.code).toBe("VALIDATION_ERROR");
});
});E2E Tests
- Test critical user journeys only -- sign up, purchase, core workflow
- Use realistic data -- not "test123" or "foo bar"
- Use data-testid attributes --
data-testid="submit-button", not CSS selectors - Handle async operations explicitly -- wait for elements, not fixed timeouts
- Run in CI against a staging environment
- Keep under 10 minutes total
Coverage Targets
| Metric | Target | Notes |
| Line coverage | 80%+ | Higher for critical modules |
| Branch coverage | 75%+ | Ensures conditional paths are tested |
| Function coverage | 85%+ | All public functions tested |
| Critical paths | 100% | Payment, auth, data integrity |
Rules
- Coverage is a floor, not a ceiling -- don't write bad tests to hit a number
- Track coverage trends -- it should go up or stay flat, never down
- Enforce in CI -- fail the build if coverage drops below the threshold
- Exclude generated code -- don't count auto-generated files, configs, or type definitions
Test File Organization
src/
services/
order.service.ts
order.service.test.ts # Unit tests colocated
api/
routes/
users.route.ts
tests/
integration/
api/
users.test.ts # Integration tests separate
e2e/
flows/
checkout.test.ts # E2E tests separate
fixtures/
users.json # Shared test data
helpers/
test-db.ts # Shared test utilitiesAnti-patterns
- Testing implementation details -- test behavior, not how it's implemented
- Snapshot overuse -- snapshots are brittle; use them for serializable output, not UI
- Flaky tests -- fix or delete them; a flaky test is worse than no test
- Test setup duplication -- extract to helper functions or fixtures
- Ignoring test failures -- a skipped test is a known bug you're choosing to keep
- 100% coverage obsession -- diminishing returns past 85%; focus on meaningful tests
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

