Test Environment Setup
Skill Purpose: Configure and maintain reliable test environments, including databases, services, and environment variables for unit, integration, and E2E testing.
Core Skill Pattern
Objective: Provide repeatable test environment setup that mirrors production-critical behavior without risking production data.
Universal Pattern:
- •Define environment tiers (local, CI, staging)
- •Provision dependencies (DB, queues, storage, auth)
- •Configure environment variables and secrets
- •Prepare test data and fixtures
- •Validate readiness with smoke checks
Key Decisions (Project-Specific):
- •Use containers vs shared staging services
- •Test database strategy (ephemeral vs persistent)
- •Secrets management in CI
- •Data reset strategy between runs
Project-Specific Implementation Notes
Customize per project:
- •Use separate test Supabase project or schema
- •Use dedicated test users and API keys
- •Keep .env.test isolated from .env
- •Seed minimal deterministic data for tests
Example Implementation (Next.js + Supabase)
Note: Example only. Adapt to your actual stack and deployment model.
Environment Layout
code
.env.test .env.ci
Example .env.test
code
NEXT_PUBLIC_SUPABASE_URL=https://test-project.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=REDACTED SUPABASE_SERVICE_ROLE_KEY=REDACTED TEST_DATABASE_URL=postgresql://postgres:postgres@localhost:54322/postgres
Readiness Check (Pseudo)
code
1) Run migrations against TEST_DATABASE_URL 2) Seed base fixtures 3) Verify auth works with test users 4) Run a minimal smoke test suite
Best Practices
- •Use disposable test data and reset between runs
- •Keep test envs isolated from production
- •Store secrets in CI secret manager only
- •Mirror production config for critical paths
- •Validate readiness before full test runs
Stop Conditions
STOP and escalate if:
- •Test environment touches production data
- •Required secrets are unavailable
- •Test services are not isolated
- •Data reset strategy is unclear
Skill Version: 1.0.0