--- name: reference_run_and_test description: How to run the service + the test-DB isolation and the replay.spec flake workaround metadata: type: reference --- **Infra:** Postgres in docker `iios-db` on **:5434** (db `iios`), Redis on :6379. If Docker is down: `open -a OrbStack` then `docker start iios-db`. **Run** (dev auth via Supabase; media + push enabled): ``` pnpm --filter @insignia/iios-service exec nest build # rebuild after backend changes SUPABASE_URL=https://.supabase.co REDIS_URL=redis://localhost:6379 PORT=3200 \ APP_SECRETS='{"portal-demo":"dev-secret"}' MEDIA_DIR=/tmp/iios-media \ VAPID_PUBLIC_KEY=… VAPID_PRIVATE_KEY=… VAPID_SUBJECT=mailto:dev@insignia \ node packages/iios-service/dist/main.js # :3200 ; GET /health ``` Restarting: `lsof -ti :3200 | xargs kill -9` first (stale instance → EADDRINUSE / old build served). **Tests:** `pnpm test` (Vitest) runs against an **isolated `iios_test` DB** (globalSetup creates + migrates it; `DATABASE_URL` overridden) — it **never wipes the dev `iios` DB**. TDD: spec next to code; DB specs use `resetDb()`. **⚠ Known flake — `outbox/replay.spec`:** clock/ordering-sensitive, pre-existing. If it fails in a full run, it's stale `iios_test` state, NOT a regression. Fix: `docker exec iios-db psql -U iios -d postgres -c "DROP DATABASE IF EXISTS iios_test WITH (FORCE)"` then re-run. Prove it's not yours by stashing changes and re-running. `pnpm boundary` = import-boundary check (must stay OK). Smokes: `packages/iios-service/scripts/smoke-*.mjs`.