← ClaudeAtlas

testinglisted

Use when writing, reviewing, or improving tests, deciding what to mock, or designing interfaces for testability.
juanibiapina/skills · ★ 4 · Testing & QA · score 65
Install: claude install-skill juanibiapina/skills
# Testing Load skill: [mocking](mocking.md) ## Interface Testing Good interfaces make testing natural: 1. **Accept dependencies, don't create them** ```typescript // Testable function processOrder(order, paymentGateway) {} // Hard to test function processOrder(order) { const gateway = new StripeGateway(); } ``` 2. **Return results, don't produce side effects** ```typescript // Testable function calculateDiscount(cart): Discount {} // Hard to test function applyDiscount(cart): void { cart.total -= discount; } ``` 3. **Small surface area** - Fewer methods = fewer tests needed - Fewer params = simpler test setup ## Good Tests **Good tests** are integration-style: they exercise real code paths through public APIs. They describe _what_ the system does, not _how_ it does it. A good test reads like a specification - "user can checkout with valid cart" tells you exactly what capability exists. These tests survive refactors because they don't care about internal structure. ```typescript // GOOD: Tests observable behavior test("user can checkout with valid cart", async () => { const cart = createCart(); cart.add(product); const result = await checkout(cart, paymentMethod); expect(result.status).toBe("confirmed"); }); ``` Characteristics: - Tests behavior users/callers care about - Uses public API only - Survives internal refactors - Describes WHAT, not HOW - One logical assertion per test ## Bad Tests **