/testing:testing-strategyfrom testing
Defines a testing strategy for TypeScript (Vitest) and Python (pytest) projects with 80%+ coverage thresholds, fixture patterns, and Doppler test environments. Includes setup instructions, examples, and templates.
Ships in testing. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Comprehensive testing approach for TypeScript (Vitest) and Python (pytest) projects.
Follow these standards when writing tests, setting up test infrastructure, or improving test coverage in Grey Haven codebases.
Grey Haven uses consistent test markers across languages:
Project Structure:
tests/
├── unit/ # Fast, isolated tests
├── integration/ # Multi-component tests
└── e2e/ # Playwright tests
Key Configuration:
// vitest.config.ts
export default defineConfig({
test: {
globals: true,
environment: "jsdom",
setupFiles: ["./tests/setup.ts"],
coverage: {
thresholds: { lines: 80, functions: 80, branches: 80, statements: 80 },
},
},
});
Running Tests:
bun run test # Run all tests
bun run test:coverage # With coverage report
bun run test:watch # Watch mode
bun run test:ui # UI mode
bun run test tests/unit/ # Unit tests only
See EXAMPLES.md for complete test examples.
Project Structure:
tests/
├── conftest.py # Shared fixtures
├── unit/ # @pytest.mark.unit
├── integration/ # @pytest.mark.integration
├── e2e/ # @pytest.mark.e2e
└── benchmark/ # @pytest.mark.benchmark
Key Configuration:
# pyproject.toml
[tool.pytest.ini_options]
addopts = ["--cov=app", "--cov-fail-under=80"]
markers = [
"unit: Fast, isolated unit tests",
"integration: Tests involving multiple components",
"e2e: End-to-end tests through full flows",
"benchmark: Performance tests",
]
Running Tests:
# ⚠️ ALWAYS activate virtual environment first!
source .venv/bin/activate
# Run with Doppler for environment variables
doppler run -- pytest # All tests
doppler run -- pytest --cov=app # With coverage
doppler run -- pytest -m unit # Unit tests only
doppler run -- pytest -m integration # Integration tests only
doppler run -- pytest -m e2e # E2E tests only
doppler run -- pytest -v # Verbose output
See EXAMPLES.md for complete test examples.
Characteristics:
Use for:
Characteristics:
Use for:
Characteristics:
Use for:
Characteristics:
Use for:
⚠️ CRITICAL: Grey Haven uses Doppler for ALL environment variables.
# Install Doppler
brew install dopplerhq/cli/doppler
# Authenticate and setup
doppler login
doppler setup
# Run tests with Doppler
doppler run -- bun run test # TypeScript
doppler run -- pytest # Python
# Use specific config
doppler run --config test -- pytest
Doppler provides:
DATABASE_URL_TEST - Test database connectionREDIS_URL - Redis for tests (separate DB)BETTER_AUTH_SECRET - Auth secretsSTRIPE_SECRET_KEY - External service keys (test mode)PLAYWRIGHT_BASE_URL - E2E test URLSee REFERENCE.md for complete setup.
// tests/factories/user.factory.ts
import { faker } from "@faker-js/faker";
export function createMockUser(overrides = {}) {
return {
id: faker.string.uuid(),
tenant_id: faker.string.uuid(),
email_address: faker.internet.email(),
name: faker.person.fullName(),
...overrides,
};
}
# tests/conftest.py
@pytest.fixture
async def test_user(session, tenant_id):
"""Create test user with tenant isolation."""
user = User(
tenant_id=tenant_id,
email_address="[email protected]",
name="Test User",
)
session.add(user)
await session.commit()
return user
See EXAMPLES.md for more patterns.
⚠️ ALWAYS test tenant isolation in multi-tenant projects:
@pytest.mark.unit
async def test_tenant_isolation(session, test_user, tenant_id):
"""Verify queries filter by tenant_id."""
repo = UserRepository(session)
# Should find with correct tenant
user = await repo.get_by_id(test_user.id, tenant_id)
assert user is not None
# Should NOT find with different tenant
different_tenant = uuid4()
user = await repo.get_by_id(test_user.id, different_tenant)
assert user is None
GitHub Actions with Doppler:
# .github/workflows/test.yml
- name: Run tests with Doppler
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN_TEST }}
run: doppler run --config test -- bun run test:coverage
See REFERENCE.md for complete workflow.
Use this skill when:
These testing patterns come from Grey Haven production templates:
cvi-template (Vitest + Playwright + React Testing Library)cvi-backend-template (pytest + FastAPI TestClient + async fixtures)source .venv/bin/activate)doppler run --config testDATABASE_URL_TEST)EXAMPLES.md (opens in a new tab)REFERENCE.md (opens in a new tab)checklists/test-quality-review.md (opens in a new tab)checklists/testing-checklist.md (opens in a new tab)scripts/coverage_check.py (opens in a new tab)scripts/run_tests.py (opens in a new tab)templates/conftest.py (opens in a new tab)templates/pytest-integration.py (opens in a new tab)templates/pytest-unit.py (opens in a new tab)templates/vitest-component.test.tsx (opens in a new tab)templates/vitest-integration.test.ts (opens in a new tab)templates/vitest-unit.test.ts (opens in a new tab)templates/vitest.config.ts (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub greyhaven-ai/claude-code-config --plugin testing3 skills in this plugin
/react-tanstack-testingSpecialized testing for React applications using TanStack ecosystem (Query, Router, Table, Form) with Vite and Vitest. Use when testing React + TanStack apps, mocking server state, testing router, or validating query behavior. Triggers: 'TanStack testing', 'React Query testing', 'test TanStack', 'mock query', 'router test'./test-generationComprehensive test suite generation with unit tests, integration tests, edge cases, and error handling. Use when generating tests for existing code, improving coverage, or creating systematic test suites. Triggers: 'generate tests', 'add tests', 'test coverage', 'write tests for', 'create test suite'.Other plugins' skills for the same job