docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Implement a helper that executes an infrastructure program entirely in-memory using the dependency's runtime mocking hook. The helper should install mocks, run the user-supplied program, expose outputs, and clean up runtime state so multiple runs do not leak state.
runWithMocks installs the runtime mock hook using the provided handlers before running the program and clears runtime state afterward. Repeated calls should not share mocks or config.clearMocks removes any installed mocks so other tests or programs can run normally.preview is true, the runtime should behave as if running a dry-run/preview: the program should observe preview mode via the dependency's preview indicator and any unknown output semantics should be preserved.preview is false or omitted, the program executes as an update run.handlers.resources is invoked for each resource registration with details about the request. Its returned id and state become the resource's result.handlers.calls (if provided) is invoked for each data-source/provider call with the request details. Its return value becomes the call result.runWithMocks returns a promise resolving to { outputs, preview }, where outputs is whatever the program returns (resolved through the dependency's output machinery) and preview echoes the mode used.Provides IaC runtime, Outputs, and mock-aware execution utilities.
export interface MockResourceRequest {
type: string;
name: string;
inputs: Record<string, any>;
provider?: string;
preview: boolean;
}
export interface MockResourceResult {
id: string;
state: Record<string, any>;
}
export interface MockCallRequest {
token: string;
inputs: Record<string, any>;
preview: boolean;
}
export interface MockHandlers {
resources(request: MockResourceRequest): Promise<MockResourceResult> | MockResourceResult;
calls?(request: MockCallRequest): Promise<Record<string, any>> | Record<string, any>;
}
export interface MockRunOptions<TOutputs> {
program: () => Promise<TOutputs>;
handlers: MockHandlers;
preview?: boolean;
}
export interface MockRunResult<TOutputs> {
outputs: TOutputs;
preview: boolean;
}
export function runWithMocks<TOutputs>(options: MockRunOptions<TOutputs>): Promise<MockRunResult<TOutputs>>;
export function clearMocks(): void;