Testing
Terra uses Vitest for unit tests and Playwright for E2E tests.
Test Stack
| Tool | Purpose |
|---|---|
| Vitest | Unit and integration tests |
| Playwright | End-to-end browser tests |
| React Testing Library | Component testing |
Running Tests
Test Structure
Load Certification
pnpm test:load runs a pass/fail capacity gate for public critical paths:
GET /status(public status lookup)GET /f/<slug>(public submission form)POST /api/drive-upload(optional when upload fixture is configured)
| Scenario | Max p95 latency | Max error rate | Min throughput |
|---|---|---|---|
| Status lookup | 1200ms | 2% | 8 rps |
| Public submission | 1500ms | 2% | 6 rps |
| Drive upload | 2500ms | 5% | 2 rps |
TERRA_LOAD_BASE_URL(required, e.g.http://127.0.0.1:3310)TERRA_LOAD_FORM_PATH(default/f/e2e-test-form)TERRA_LOAD_REQUESTS(default120)TERRA_LOAD_CONCURRENCY(default12)TERRA_LOAD_INCLUDE_UPLOAD=trueTERRA_LOAD_UPLOAD_PATH(include query params; use{{index}}insubmissionIdto avoid collisions)- Per-scenario SLO overrides:
TERRA_LOAD_STATUS_MAX_P95_MS,TERRA_LOAD_SUBMISSION_MAX_ERROR_RATE,TERRA_LOAD_UPLOAD_MIN_RPS, etc.
TERRA_LOAD_ALLOW_MISSING_FIXTURES=true.
Deterministic Time-Based Tests
If a test depends on “last 7 days” / “last 30 days” logic, freeze time and use explicit timestamps.- Prevents flaky tests caused by local clock drift or timezone differences.
- Makes date-window assertions stable in CI.
- Keeps failures tied to logic regressions, not timing noise.