Skip to content

Latest commit

 

History

History
116 lines (70 loc) · 2.32 KB

File metadata and controls

116 lines (70 loc) · 2.32 KB

Testing

My Reps tests are organized around seams. Each seam has a small public contract and focused tests.

Core Contract

Files:

  • src/core/validation.test.ts
  • src/core/lookup.test.ts
  • src/core/openStatesSource.test.ts

These tests cover input validation, mock lookup behavior, live source behavior, coverage metadata, source error mapping, and privacy guarantees. Most behavior changes should start here.

Run a core test file:

npx vitest run src/core/lookup.test.ts

API Adapter

File:

  • src/api/lookup.test.ts

These tests cover HTTP request parsing, method handling, status code mapping, live env wiring, API headers, and sanitized failures.

The API should stay thin. If an API test needs a lot of domain setup, that usually means the behavior belongs in src/core.

Run it:

npx vitest run src/api/lookup.test.ts

CLI Adapter

File:

  • src/cli/georep.test.ts

These tests cover command parsing, JSON output, exit codes, schema, source-status, and privacy behavior from the terminal surface.

Run it:

npx vitest run src/cli/georep.test.ts

Web UI

File:

  • src/web/App.test.tsx

These tests cover the browser-facing states without starting Cloudflare: success, validation errors, no results, partial coverage, source failures, transport failures, and basic interaction behavior.

Run it:

npx vitest run src/web/App.test.tsx

Smoke Tests

Files:

  • scripts/smoke-lookup.mjs
  • scripts/smoke-lookup.test.mjs

The smoke script checks a running deployment or preview by posting to /api/lookup and verifying the envelope shape.

Run against a local preview:

npm run pages:preview
npm run smoke:lookup -- http://127.0.0.1:8788

Browser E2E

Files:

  • tests/e2e/public-demo.spec.ts
  • playwright.config.ts

The e2e suite starts the Cloudflare Pages-style preview in mock mode and checks the public demo path in Chromium.

Run it:

npm run test:e2e

If Chromium cannot launch, install Playwright dependencies:

npx playwright install --with-deps chromium

Security And Dependency Checks

Production dependency audit:

npm audit --omit=dev

Full dev audit:

npm audit

The full dev audit currently reports moderate Vite/Vitest toolchain advisories that require major upgrades. Production dependencies audit cleanly.