Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

v0.0.21

Compare
Choose a tag to compare
@github-actions github-actions released this 15 Jul 22:33
· 122 commits to future since this release

Release Notes

feat: support CSF3 format (#37)

Features

Storybook released CSF3, where the story can also be an object. This is now supported in @storybook/testing-react. CSF3 also brings a new function called play, where you can write automated interactions to the story.

In @storybook/testing-react, the play does not run automatically for you, but rather comes in the returned component, and you can execute it as you please.

Consider the following example:

export const InputFieldFilled: Story<InputFieldProps> = {
  play: async () => {
    await userEvent.type(screen.getByRole('textbox'), 'Hello world!');
  },
};

You can use the play function like this:

const { InputFieldFilled } = composeStories(stories);

test('renders with play function', async () => {
  render(<InputFieldFilled />);

  // play an interaction that fills the input
  await InputFieldFilled.play!();

  const input = screen.getByRole('textbox') as HTMLInputElement;
  expect(input.value).toEqual('Hello world!');
});

🐛 Bug Fix

Authors: 1