1296555f17
- Extract evaluateCondition + rule types into src/lib/rules.ts for testability - 48 unit tests for evaluateCondition (all fields/operators) and formatCategory - 21 integration tests for getTransactions filters and getParticipantBalances - Vitest configs for unit (vitest.config.ts) and integration (vitest.integration.config.ts) - setup-test-db.sh creates personal_test DB from production schema via pg_dump - Use vi.doMock + dynamic import pattern to isolate test DB from Prisma singleton
25 lines
810 B
TypeScript
25 lines
810 B
TypeScript
import { defineConfig } from "vitest/config";
|
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
import { readFileSync, existsSync } from "fs";
|
|
import { resolve } from "path";
|
|
|
|
// Load .env.test into process.env HERE, at config-load time.
|
|
// Forked workers inherit the parent process env, so Prisma's singleton
|
|
// will see the test DATABASE_URL when db.ts is first imported.
|
|
const envTestPath = resolve(__dirname, ".env.test");
|
|
if (existsSync(envTestPath)) {
|
|
for (const line of readFileSync(envTestPath, "utf-8").split("\n")) {
|
|
const m = line.match(/^([^#=]+)=(.*)/);
|
|
if (m) process.env[m[1].trim()] = m[2].trim();
|
|
}
|
|
}
|
|
|
|
export default defineConfig({
|
|
plugins: [tsconfigPaths()],
|
|
test: {
|
|
environment: "node",
|
|
include: ["src/__tests__/integration/**/*.test.ts"],
|
|
pool: "forks",
|
|
},
|
|
});
|