Test database is separate from dev database
Why it matters
When the test and development database URLs are identical, every test run that inserts, updates, or deletes records modifies the database you actively develop against. Count-based assertions drift over runs. A deleteMany in a cleanup hook that lacks a proper where clause can truncate tables you were relying on. More commonly, accumulating test records cause unique-constraint failures mid-development that look like bugs in new code. ISO-25010:2011 recoverability requires that test execution be reversible and isolated.
Severity rationale
Info because sharing dev and test DB is typically caught before catastrophic data loss, but it is a persistent source of confusion and intermittent failures.
Remediation
Ensure the database name suffix in .env.test differs from the one in .env or .env.example. Load .env.test explicitly in your test runner so there is no path through which tests can reach the dev database:
# .env (development)
DATABASE_URL=postgresql://user:pass@localhost:5432/myapp_dev
# .env.test (test — different DB name)
DATABASE_URL=postgresql://user:pass@localhost:5432/myapp_test
// package.json
{
"scripts": {
"test": "dotenv -e .env.test -- vitest run"
}
}
Confirm isolation by running npx tsx -e "console.log(process.env.DATABASE_URL)" before and after loading the test env.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Test Reality Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · reliability.recoverability — Recoverability (reliability sub-characteristic)
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ai-slop-test-theater·automated