Function: withTestEngine()
withTestEngine<
T,C>(parts,fn): (context) =>Promise<void>
Defined in: storybook/src/withTestEngine.ts:21
Build a Storybook play function around a ready, canvas-scoped test engine.
The returned function creates the engine from the play context's
canvasElement, passes the full play context through to fn augmented with
engine (typed from parts), and cleans the engine up afterwards — no
canvasElement or framework plumbing in the story.
Type Parameters​
T​
T extends ScenePart
C​
C extends StorybookPlayContext = StorybookPlayContext
Parameters​
parts​
T
fn​
(context) => Promise<void>
Returns​
(context) => Promise<void>
Example​
export const Filled: Story = {
play: withTestEngine(parts, async ({ engine, args }) => {
await engine.parts.input.setValue('hello');
}),
};