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.
Extends
Section titled “Extends”Adapter<{category:"capture-runner";targets?: readonlyRunnerTarget[]; }>
Properties
Section titled “Properties”lifecycle?
Section titled “lifecycle?”
readonlyoptionallifecycle?:AdapterLifecycle
Defined in: packages/core/src/adapters/metadata.ts:84
Optional lifecycle hooks.
Inherited from
Section titled “Inherited from”metadata
Section titled “metadata”
readonlymetadata:AdapterMetadata&object
Defined in: packages/core/src/adapters/metadata.ts:82
Adapter identity (mandatory).
Type Declaration
Section titled “Type Declaration”category
Section titled “category”
readonlycategory:"capture-runner"
targets?
Section titled “targets?”
readonlyoptionaltargets?: readonlyRunnerTarget[]
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.
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”cancel()
Section titled “cancel()”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.
Parameters
Section titled “Parameters”buildId
Section titled “buildId”string
runId?
Section titled “runId?”string
Returns
Section titled “Returns”Promise<void>
extractParameters()?
Section titled “extractParameters()?”
optionalextractParameters(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.
Parameters
Section titled “Parameters”adapter?
Section titled “adapter?”buildId
Section titled “buildId”string
logger?
Section titled “logger?”stories
Section titled “stories”storybookDir
Section titled “storybookDir”string
storybookUrl?
Section titled “storybookUrl?”string
As on render: the URL a reach: "url" target’s browser opens.
target?
Section titled “target?”Target to read the parameters on: the project’s primary (chromium when absent).
Returns
Section titled “Returns”Promise<Record<string, StoryParameters>>
render()
Section titled “render()”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.
Parameters
Section titled “Parameters”Render request with the extracted Storybook directory.
adapter?
Section titled “adapter?”Test/extension seam: override the story source adapter (defaults to
StorybookAdapter). Only the renderer uses it; discovery stays the
orchestrator’s job.
buildId
Section titled “buildId”string
Build being captured, used to correlate cancels with in-flight work.
executePlay?
Section titled “executePlay?”boolean
Whether to execute Storybook play functions before screenshot.
logger?
Section titled “logger?”Optional logger for render-time diagnostics.
onCapture?
Section titled “onCapture?”(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.
playTimeoutMs?
Section titled “playTimeoutMs?”number
Timeout for play function execution in ms.
runA11y?
Section titled “runA11y?”boolean
Whether to run a11y checks (axe) before screenshot; annotated as non-blocking.
runId?
Section titled “runId?”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.
stories
Section titled “stories”Stories to render.
storybookDir
Section titled “storybookDir”string
Root of the already-extracted Storybook build.
storybookUrl?
Section titled “storybookUrl?”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.
target?
Section titled “target?”Target to render on (chromium when absent).
viewports
Section titled “viewports”Viewport[]
Viewports to capture.
Returns
Section titled “Returns”Promise<RenderResult>
runTests()?
Section titled “runTests()?”
optionalrunTests(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.
Parameters
Section titled “Parameters”adapter?
Section titled “adapter?”buildId
Section titled “buildId”string
logger?
Section titled “logger?”playTimeoutMs?
Section titled “playTimeoutMs?”number
Timeout for one test (render plus body) in ms.
runId?
Section titled “runId?”string
storybookDir
Section titled “storybookDir”string
storybookUrl?
Section titled “storybookUrl?”string
As on render: the URL a reach: "url" target’s browser opens.
target?
Section titled “target?”Target to run on: the project’s primary (chromium when absent).
The test entries to run (StoryEntry.parentId is set).
Returns
Section titled “Returns”Promise<TestOutcome[]>
setLogger()?
Section titled “setLogger()?”
optionalsetLogger(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).
Parameters
Section titled “Parameters”logger
Section titled “logger”Returns
Section titled “Returns”void