test(integration): add real-stack integration test suite with PGlite
Docker Image CI / test (push) Successful in 1m47s
Tests / unit (push) Successful in 57s
Tests / integration (push) Successful in 1m38s
Docker Image CI / deploy (push) Failing after 8s

- PGlite (in-memory WASM Postgres) hosted in a child process, exposed
  via TCP socket; real migrations applied with prisma migrate deploy
- Vitest harness (vitest.integration.config.ts, global-setup spawns
  PGlite + built Nuxt server, per-test TRUNCATE, factories, cookie-jar
  API client); no mocks, zero production code changes
- 50 tests across auth, hunt, team, submit, review, showcase, diashow
  incl. SuperJSON envelope check; *.itest.ts keeps bun test untouched
- CI: parallel unit + integration jobs in .github/workflows/test.yml
- tests/ covered by nuxt typecheck via tests/tsconfig.json reference
This commit is contained in:
2026-08-13 23:10:07 +02:00
parent 28714a8cbc
commit 01d1e5fb60
22 changed files with 1813 additions and 49 deletions
+19
View File
@@ -0,0 +1,19 @@
import { prisma } from '../integration/setup';
/**
* Truncates every table in the public schema (except _prisma_migrations)
* so each test starts from an empty database. Sequences are reset to keep
* autoincrement ids predictable.
*/
export async function resetDatabase() {
const tables = await prisma.$queryRawUnsafe<{ tablename: string }[]>(
`SELECT tablename::text AS tablename FROM pg_tables
WHERE schemaname = 'public' AND tablename <> '_prisma_migrations'`
);
if (tables.length === 0) return;
const list = tables.map(({ tablename }) => `"public"."${tablename}"`);
await prisma.$executeRawUnsafe(
`TRUNCATE ${list.join(', ')} RESTART IDENTITY CASCADE;`
);
}