histoire
Version:
A fast story book powered by Vite
68 lines • 3.36 kB
TypeScript
import type { InlineConfig as ViteInlineConfig } from 'vite';
import type { Vitest } from 'vitest/node';
import type { VitestRunActivity } from './vitest-start-timeout.js';
/**
* Everything one attempt of a Vitest browser run needs.
*
* Rebuilt for every attempt: the config carries live plugin instances bound to
* the Vite server of the attempt that created them, and reusing them across two
* Vitest servers hands the second one already-closed handles.
*/
export interface VitestAttemptSetup<TContext> {
/** Options passed to `createVitest`. */
vitestOptions: Record<string, any>;
/** Vite config passed to `createVitest`. */
viteConfig?: ViteInlineConfig;
/** Project-level browser options assigned right after creation. */
browserProjectOptions?: {
plugins: any[];
};
/** Prepare reachable browser dependencies before executing generated specs. */
prepareBrowser?: boolean;
/** Test name filters passed to `vitest.start()`. */
filter?: string[];
/** Maximum time `vitest.start()` may take, or go without activity when `activity` is set, before the run is considered stuck. */
timeoutMs: number;
/** Progress signal restarting the timeout (see {@link runWithVitestStartTimeout}). */
activity?: VitestRunActivity;
/** Message of the error thrown when the start times out. */
timeoutMessage: string;
/** Prints diagnostics about a stuck run. */
onTimeout?: (vitest: Vitest) => void;
/** Attempt-scoped data (generated specs, result channel…) handed to `read`. */
context: TContext;
}
export interface RunVitestAttemptsOptions<TContext, TResult> {
/** Absolute collection budget inherited from eligibility and isolated process startup. */
deadline?: number;
/** Correlates opt-in runner phase timings with streamed collection results. */
runId?: string;
/** Collection executes modules without executing assertion bodies or lifecycle hooks. */
mode?: 'run' | 'collect';
/** Project install used for Node and browser Vitest APIs. */
root: string;
/** Controller-owned cancellation. */
signal?: AbortSignal;
/** Require confirmed runner/server teardown before lane reuse. */
strictCleanup?: boolean;
/** Human-readable name of the run, used in cleanup diagnostics. */
label: string;
/** Warning printed when the run is retried. */
retryMessage: string;
/** How many times the run may be retried after a browser crash. */
maxRetries?: number;
/** Builds the setup of one attempt (see {@link VitestAttemptSetup}). */
setup: () => Promise<VitestAttemptSetup<TContext>>;
/** Reads the finished run; its return value is the result of the whole run. */
read: (vitest: Vitest, context: TContext) => TResult | Promise<TResult>;
}
/**
* Runs a Vitest browser run, retrying it once when the browser crashed.
*
* Shared by the story collection and the test execution: both create a Vitest
* instance from a freshly built config, start it under a safety timeout, read
* the outcome and tear the instance down on every path.
* @param options Run configuration (see {@link RunVitestAttemptsOptions}).
*/
export declare function runVitestAttempts<TContext, TResult>(options: RunVitestAttemptsOptions<TContext, TResult>): Promise<TResult>;
//# sourceMappingURL=vitest-run.d.ts.map