ClaudetestingTesting

Testing Claude Rules

Claude rules for writing high-quality tests: test pyramid strategy, mocking principles, and CI integration.

CLAUDE.md
- Follow the testing pyramid: many unit tests, fewer integration tests, few E2E tests
- Use dependency injection to make all code testable without mocking frameworks
- Test through the public API of modules; avoid testing private implementation
- Use realistic test data with factories; avoid magic strings and numbers
- Write E2E tests for critical user journeys (signup, checkout, auth flows)
- Use Playwright for E2E tests; run them against a staging environment in CI
- Measure mutation score with Stryker to assess test quality beyond coverage
- Make flaky tests a P1 bug; never commit tests that pass intermittently

How to use with Claude

Create a `CLAUDE.md` file in your project root. Claude Code reads this on startup and follows your conventions throughout the session.

#testing#claude#e2e#unit-tests#coding-rules

Related Rules