UNPKG

@accounter/server

Version:
18 lines (17 loc) 769 B
import type { Pool, PoolClient } from 'pg'; /** * Sets up Vitest lifecycle hooks for transactional isolation. * - Creates isolated temp env file if TEST_ENV_FILE not set. * - Connects a shared pool once. * - Opens a fresh transaction before each test and rolls back after. * - Optionally seeds the admin core inside each test transaction (idempotent). * * NOTE: Migrations are expected to be applied externally; this helper only asserts runtime isolation. */ export declare function setupDbHooks(options?: { seedAdminInEachTest?: boolean; }): void; /** Access the active transactional client for the current test. */ export declare function getTestClient(): PoolClient; /** Access the underlying shared pool. */ export declare function getTestPool(): Pool;