vitest.db.config.ts
Rama main · réplica de lectura del repositorio original.
import { defineConfig } from 'vitest/config'
import { fileURLToPath } from 'node:url'
/**
* Database tests, separate from the unit suite because they need a real
* Postgres with the migrations applied. They are their own CI job for the same
* reason -- and because a failure here means the tenant boundary is broken,
* which deserves to be its own red light rather than one line among hundreds.
*/
export default defineConfig({
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'@gw/edition': fileURLToPath(new URL('./src/server/edition/community.ts', import.meta.url)),
// The empty catalogue. A test that wants designs mocks this module;
// the private implementation is not in this repository at all.
'@gw/catalog': fileURLToPath(new URL('./src/cloud/catalog/unavailable.ts', import.meta.url)),
'@gw/billing-adapters': fileURLToPath(
new URL('./src/cloud/billing/adapters/unavailable.ts', import.meta.url),
),
'@gw/home': fileURLToPath(
new URL('./src/components/home/community-home.tsx', import.meta.url),
),
},
},
test: {
environment: 'node',
globals: true,
include: ['src/**/*.db.test.ts'],
// Against a database with the cloud migrations applied -- see
// vitest.cloud.db.config.ts. One membership per person there would break the
// tests here that deliberately put one person into two tenants.
exclude: ['**/node_modules/**', 'src/**/*.cloud.db.test.ts'],
// One connection pool, one migration state: parallel files would fight.
fileParallelism: false,
testTimeout: 20_000,
env: {
DATABASE_URL: process.env.DATABASE_URL ?? 'postgres://gw_app@127.0.0.1:5433/goodworkshop',
OPS_DATABASE_URL:
process.env.OPS_DATABASE_URL ?? 'postgres://gw_ops@127.0.0.1:5433/goodworkshop',
},
},
})