test: npm test starts a throwaway Postgres when TEST_DATABASE_URL is unset

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfmHGGiYUjNcvJoyzdf
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-01 11:56:11 +08:00
1 parent f78bd635a2
commit 20e07e9d80
4 files changed
+19 -3

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@ docker run -d --name ins-pg -e POSTGRES_USER=ins -e POSTGRES_DB=ins -e POSTGRES_
-p 127.0.0.1:5432:5432 postgres:18
npm ci
DATABASE_URL=postgres://ins:devpass@127.0.0.1:5432/ins npm start # http://localhost:3000
TEST_DATABASE_URL=postgres://ins:devpass@127.0.0.1:5432/ins npm test
npm test # starts a throwaway Postgres in Docker, or uses TEST_DATABASE_URL if set
```
Environment: `DATABASE_URL` (required), `PORT` (default `3000`). Tests create their own schema in `TEST_DATABASE_URL` and drop it afterwards; they never touch an existing `leads` table.