Skip to content
Discussion options

You must be logged in to vote

Use the renderer and the component's prop type as the two type arguments to StoryContext. That gives the shared step the same args shape without extracting a parameter from the overloaded meta.story method.

import type { ComponentProps } from 'react';
import type { ReactRenderer } from '@storybook/react';
import type { StoryContext } from 'storybook/internal/csf';
import { expect } from 'storybook/test';

type ButtonPlayContext = StoryContext<
  ReactRenderer,
  ComponentProps<typeof Button>
>;

async function checkButton({ args, canvas, step }: ButtonPlayContext) {
  await step('Check the button', async () => {
    await expect(canvas.getByRole('button', { name: args.label })).toBeVisible()

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@oleksandr-danylchenko
Comment options

Comment options

You must be logged in to vote
1 reply
@oleksandr-danylchenko
Comment options

Answer selected by oleksandr-danylchenko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants