import { defineConfig } from "vitest/config"; // 两组测试: // unit —— 纯内存、无 PG,文件并行; // pg —— 真实 PG 的集成/e2e(每文件独立业务 schema + 引擎 schema,真实 worker/后台循环),文件级串行, // 并排在 unit 之后(groupOrder)。并发全量跑时多个 e2e 的 worker/轮询/迁移互相抢 CPU 与连接, // 会把"入库→状态推进"这类时序拉长到超时,也会放大竞态;串行让每个文件拿到稳定的时序预算。 // 新测试文件缺省归入 pg(串行,安全);确认不碰 PG 的才加进 UNIT。 const UNIT = [ "test/api-registry.test.ts", "test/file-manager/preview-parse.test.ts", "test/auth.test.ts", "test/health.test.ts", "test/sources-identity/identity-differential.test.ts", "test/invoke-limits.test.ts", "test/logger.test.ts", "test/mapping-compat.test.ts", "test/modules.test.ts", "test/sse.test.ts", "test/static.test.ts", ]; export default defineConfig({ test: { // 建/删 schema 在一把咨询锁上排队(withSchemaLock),迁移 + 引擎 schema 在负载下可能超过缺省 10s hookTimeout: 120_000, teardownTimeout: 60_000, projects: [ { extends: true, test: { name: "unit", include: UNIT } }, { extends: true, test: { name: "pg", include: ["test/**/*.test.ts", "src/**/*.test.ts"], exclude: UNIT, fileParallelism: false, sequence: { groupOrder: 1 }, }, }, ], }, });