histoire
Version:
A fast story book powered by Vite
34 lines • 1.76 kB
TypeScript
/** Progress signal of a run: each `touch()` restarts its stall timeout. */
export interface VitestRunActivity {
/** Reports progress (a finished spec). */
touch: () => void;
/** Sets the listener notified on every `touch()`. */
listen: (listener: (() => void) | undefined) => void;
}
/** Creates the progress signal a run's reporter touches and its stall timeout listens to. */
export declare function createVitestRunActivity(): VitestRunActivity;
export interface VitestStartTimeoutOptions {
/** Maximum time (ms) the run may take, or go without activity when `activity` is set, before it is considered stuck. */
timeoutMs: number;
/** Restarts the timer on every progress report, turning it into a stall timeout. */
activity?: VitestRunActivity;
/** Message of the error thrown when the run times out. */
message: string;
/** Prints diagnostics about the stuck run. Failures are swallowed. */
onTimeout: () => void;
}
/**
* Runs a Vitest browser run under a safety timeout.
*
* `vitest.start()` can hang forever when the browser pool never finishes
* initializing (missing Playwright browsers, a page that never loads), which
* would wedge the CLI or a dev-server request with no output at all.
*
* The timer is unref'd so it never keeps the process alive on its own, and it is
* cleared on every path (success, rejection, retry) so it can neither leak nor
* fire on an already-closed Vitest instance.
* @param run Starts the Vitest run.
* @param options Timeout configuration (see {@link VitestStartTimeoutOptions}).
*/
export declare function runWithVitestStartTimeout(run: () => Promise<unknown>, options: VitestStartTimeoutOptions): Promise<void>;
//# sourceMappingURL=vitest-start-timeout.d.ts.map