import type { DB } from '../data/db/index.js'; import type { Blueprint } from '../core/config/index.js'; import type { Manifold } from '../core/pipework.js'; import { type TestContext } from './plugin.js'; export { type TestContext, type TestDatabaseConnections } from './plugin.js'; export declare function _setTestState(instance: Manifold, testContext?: TestContext | null): void; export declare function setupPipeworkTests(configOrInstance: Blueprint | Manifold): Manifold; export declare function useTestDb(name?: string): DB; export declare function useSetupDb(name?: string): DB; /** * Register a setup connection directly. Internal: the only caller outside this module * is the test that proves a close failure is named rather than swallowed (#395), which * needs a connection whose `close` rejects. */ export declare function _registerSetupConnection(database: string, conn: { drizzle: DB; close: () => Promise; }): void; /** * Close every connection `useSetupDb()` has opened, and forget them. * * The harness closes these in `setupPipeworkTests`' own `afterAll`. Under * vitest's `sequence.hooks: 'stack'` that hook runs *after* a consumer's * setupFile `afterAll`, so a teardown-time observer — one sampling * `pg_stat_activity` to name leaked backends, say — sees every setup * connection still open and cannot tell them from a real leak. Call this * first, then sample: what remains is a true survivor set. * * Idempotent, and safe to call before the harness's own teardown — that * teardown still closes the pool and drops the databases afterwards. A later * `useSetupDb()` opens a fresh connection. */ export declare function closeSetupConnections(): Promise; /** * A setup connection refused to close. * * Names every database whose connection would not close and the underlying error, * because the backend is still held: the alternative is a leak with no record, found * later as an unexplained pid or a hook that never finishes. */ export declare class SetupConnectionCloseError extends Error { readonly failures: ReadonlyArray<{ database: string; cause: unknown; }>; constructor(failures: ReadonlyArray<{ database: string; cause: unknown; }>); } /** * The harness's own `afterAll`: close setup connections, the pool, the databases. * * A setup connection that will not close must not cost the pool and the databases * their teardown — that would trade one leak for many. Every step runs, and the close * failure is raised at the end so the file fails by name (#395). */ export declare function teardownAfterAll(instance: Manifold): Promise; export declare function _isInTestIsolation(): boolean; export declare function useTestInstance(): Manifold; export interface WithFlowOptions { auth?: unknown; tenant?: string | null; } export declare function withFlow(fn: () => T): Promise>; export declare function withFlow(options: WithFlowOptions, fn: () => T): Promise>; //# sourceMappingURL=vitest.d.ts.map