// "Grey Haven's comprehensive testing strategy - Vitest unit/integration/e2e for TypeScript, pytest markers for Python, >80% coverage requirement, fixture patterns, and Doppler for test environments. Use when writing tests, setting up test infrastructure, running tests, debugging test failures, improving coverage, configuring CI/CD, or when user mentions 'test', 'testing', 'pytest', 'vitest', 'coverage', 'TDD', 'test-driven development', 'unit test', 'integration test', 'e2e', 'end-to-end', 'test fixtures', 'mocking', 'test setup', 'CI testing'."
| name | grey-haven-testing-strategy |
| description | Grey Haven's comprehensive testing strategy - Vitest unit/integration/e2e for TypeScript, pytest markers for Python, >80% coverage requirement, fixture patterns, and Doppler for test environments. Use when writing tests, setting up test infrastructure, running tests, debugging test failures, improving coverage, configuring CI/CD, or when user mentions 'test', 'testing', 'pytest', 'vitest', 'coverage', 'TDD', 'test-driven development', 'unit test', 'integration test', 'e2e', 'end-to-end', 'test fixtures', 'mocking', 'test setup', 'CI testing'. |
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="test@example.com",
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)