Writes behavior-focused tests using Testing Trophy model with real dependencies. Use when writing tests, choosing test types, or avoiding anti-patterns like testing mocks.
If the current repo has its own rules/skills covering this topic (check .claude/rules/ and repo CLAUDE.md), those take precedence — apply this skill only where they're silent.
Core principle: Test user-observable behavior with real dependencies. Tests should survive refactoring.
"The more your tests resemble the way your software is used, the more confidence they can give you." — Kent C. Dodds
Why this matters: Tests exist to give you confidence. The Testing Trophy prioritizes integration tests because they test real behavior across real modules — giving maximum confidence per test written. Unit tests in isolation often just test mocks, not your actual system.
| Priority | Type | When | | -------- | ----------- | ----------------------------------------------- | | 1st | Integration | Default - multiple units with real dependencies | | 2nd | E2E | Complete user workflows | | 3rd | Unit | Pure functions only (no dependencies) |
Default: Don't mock. Use real dependencies.
Only mock:
Never mock:
Before mocking, ask: "What side effects does this have? Does my test need those?" If unsure, run with real implementation first, then add minimal mocking only where needed.
Complete user workflow? → E2E test
Pure function (no side effects)? → Unit test
Everything else → Integration test
| Context | Assert On | Avoid | | ------- | --------------------- | --------------------------- | | UI | Visible text, roles | CSS classes, internal state | | API | Response body, status | Internal DB state | | Library | Return values | Private methods |
| Pattern | Fix |
| ------------------------------- | --------------------------- |
| Testing mock calls | Test actual outcome |
| Test-only methods in production | Move to test utilities |
| sleep(500) | Poll for actual condition |
| Asserting on internal state | Assert on observable output |
| Incomplete mocks | Mirror real API completely |
Wait for the actual condition, not a guess about how long it takes.
// Bad: arbitrary delay
await new Promise(r => setTimeout(r, 2000));
expect(element).toBeVisible();
// Good: poll for condition
await waitFor(() => expect(element).toBeVisible());
Prefer framework built-ins:
findBy queries, waitForexpect(locator).toBeVisible()asyncio.wait_for, tenacityLanguage-specific waiting patterns:
Remember: Behavior over implementation. Real over mocked. Outputs over internals.
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer