import { type Problem } from "./gate.ts"; export interface TestPrepareOptions { /** App source directory (colocated `*.test.ts` files are tests too). */ src: string; /** Separate test directory, when the app has one. */ tests?: string; /** Output directory; deleted and recreated. */ out: string; } export interface TestPlanEntry { /** Absolute path of the test file as written. */ source: string; /** Absolute path of the prepared ES module that `node-app-burger test` runs. */ output: string; } /** `/test-plan.json`, read by `node-app test`. */ export interface TestPlan { importMap: string; tests: TestPlanEntry[]; } /** `/importmap.json` (Contract C8). */ export interface ImportMap { imports: Record; } export type TestPrepareOutcome = { ok: true; plan: TestPlan; importMap: ImportMap; } | { ok: false; report: string; }; export declare function commonAncestor(dirs: readonly string[]): string; /** `tests/db.test.ts` → `tests/db.test.js`. */ export declare function preparedPath(relativePath: string): string; /** `@econ-v1/app-sdk` → `econ-v1__app-sdk.js`. */ export declare function dependencyFileName(specifier: string): string; interface Workspace { root: string; sources: ReadonlySet; jsonFiles: Set; dependencies: Set; problems: Problem[]; } /** * What a prepared module imports instead of `specifier` (written in * `importer`). Returns undefined — with a recorded problem — when the import * cannot work under Burger. */ export declare function rewriteSpecifier(ws: Workspace, importer: string, specifier: string): string | undefined; /** * Problems for a module that statically imports a module it also replaces * with `mock.module`. Bun patches the already-linked bindings, so the test * passes there; Burger links static imports before any code runs, so the * test would silently exercise the real module. */ export declare function staticallyImportedMocks(file: string, code: string, imports: readonly { kind: string; path: string; }[]): string[]; /** * Turn an app's sources and tests into files `node-app-burger test` can run: * one transpiled ES module per source file (module boundaries preserved so * `mock.module` can replace them), one pre-bundled file per bare * dependency specifier, and `importmap.json` (Contract C8). */ export declare function prepareTests(options: TestPrepareOptions): Promise; export {};