Skip to content

CaptureRunner

Defined in: packages/core/src/adapters/capture-runner.ts:149

A pure capture renderer.

Adapters implementing CaptureRunner render screenshots from an already-extracted Storybook directory and return PNG buffers. They are intentionally pure: they perform no database, storage, or build-state management. Loading the build, extracting the uploaded archive, persisting snapshots/baselines/diffs, and advancing build status are the capture orchestrator’s job (see capture/orchestrator.ts), keeping every adapter implementation free of server concerns.

readonly optional lifecycle?: AdapterLifecycle

Defined in: packages/core/src/adapters/metadata.ts:84

Optional lifecycle hooks.

Adapter.lifecycle


readonly metadata: AdapterMetadata & object

Defined in: packages/core/src/adapters/metadata.ts:82

Adapter identity (mandatory).

readonly category: "capture-runner"

readonly optional targets?: readonly RunnerTarget[]

Every target the runner offers, default first (ADR 0007, decision 1), with whether each can render now. A runner that omits it offers any target.

Adapter.metadata

cancel(buildId, runId?): Promise<void>

Defined in: packages/core/src/adapters/capture-runner.ts:255

Cancel in-flight renders of a build: the ones started with runId, or every one of the build when it is absent. Runners can track their calls with RenderRuns.

string

string

Promise<void>


optional extractParameters(input): Promise<Record<string, StoryParameters>>

Defined in: packages/core/src/adapters/capture-runner.ts:216

Optional pre-pass reading each story’s fully resolved parameters (project, component and story levels stacked) from the running preview. Storybook’s index rarely carries parameters, so this is how the orchestrator learns which modes a story declares before it builds the capture matrix. Absent or failing, the orchestrator falls back to index parameters.

StorySourceAdapter

string

Logger

StoryEntry[]

string

string

As on render: the URL a reach: "url" target’s browser opens.

CaptureTarget

Target to read the parameters on: the project’s primary (chromium when absent).

Promise<Record<string, StoryParameters>>


render(input): Promise<RenderResult>

Defined in: packages/core/src/adapters/capture-runner.ts:163

Render configured viewports for the given stories of an extracted Storybook and return the screenshot buffers.

Render request with the extracted Storybook directory.

StorySourceAdapter

Test/extension seam: override the story source adapter (defaults to StorybookAdapter). Only the renderer uses it; discovery stays the orchestrator’s job.

string

Build being captured, used to correlate cancels with in-flight work.

boolean

Whether to execute Storybook play functions before screenshot.

Logger

Optional logger for render-time diagnostics.

(capture) => Promise<void>

Optional streaming hand-off. When provided, the runner awaits it with each capture as soon as it is taken, then drops the buffer instead of adding the capture to RenderResult.captures, so a large build never holds every screenshot in memory. A rejection is reported as a render failure for that story/viewport. Runners that do not support it return captures as usual.

number

Timeout for play function execution in ms.

boolean

Whether to run a11y checks (axe) before screenshot; annotated as non-blocking.

string

This call’s handle within the build, for cancel(buildId, runId): several renders of one build (its shards) can be in flight in one process. Absent, the build id is used.

StoryEntry[]

Stories to render.

string

Root of the already-extracted Storybook build.

string

An absolute URL to the build’s Storybook that the target’s browser can reach, set for a reach: "url" target (ADR 0007, decision 5). The runner navigates there instead of to its loopback server; a reach: "url" target given none fails to start. Never logged.

CaptureTarget

Target to render on (chromium when absent).

Viewport[]

Viewports to capture.

Promise<RenderResult>


optional runTests(input): Promise<TestOutcome[]>

Defined in: packages/core/src/adapters/capture-runner.ts:235

Optional: run Storybook 10 .test() entries (index subtype: "test") as interaction tests. Each entry’s iframe URL renders the story it is written under and runs the test body as the play function; the runner reports pass or fail per entry from Storybook’s own events, and takes no screenshot. A runner without it leaves projects that turn tests on with a warning. Cancellable with cancel, like render.

StorySourceAdapter

string

Logger

number

Timeout for one test (render plus body) in ms.

string

string

string

As on render: the URL a reach: "url" target’s browser opens.

CaptureTarget

Target to run on: the project’s primary (chromium when absent).

StoryEntry[]

The test entries to run (StoryEntry.parentId is set).

Promise<TestOutcome[]>


optional setLogger(logger): void

Defined in: packages/core/src/adapters/metadata.ts:90

Bind the host-owned runtime logger. Called by the app/worker when present; factories must never create their own loggers — they only store what they are given (explicit options.logger wins over bound).

Logger

void

Adapter.setLogger