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

Version 1.0.0 #60

Merged
merged 18 commits into from
Nov 22, 2021
Merged

Version 1.0.0 #60

merged 18 commits into from
Nov 22, 2021

Conversation

yannbf
Copy link
Member

@yannbf yannbf commented Nov 18, 2021

Issue: N/A

What Changed

Checklist

Check the ones applicable to your change:

  • Tests are updated
  • Documentation is updated

Change Type

Indicate the type of change your pull request is:

  • documentation
  • patch
  • minor
  • major

Release Notes

Breaking changes

Updates Storybook peer dependency to 6.4

Features

CSF3

Storybook 6.4 released a new version of CSF, where the story can also be an object. This is supported in @storybook/testing-react, but you have to match the requisites:

1 - Either your story has a render method or your meta contains a component property:

// Example 1: Meta with component property
export default {
  title: 'Button',
  component: Button // <-- This is strictly necessary
}

// Example 2: Story with render method:
export const Primary = {
  render: (args) => <Button {...args}>
}

Play function

Storybook 6.4 also brings a new function called play, where you can write automated interactions to the story.

In @storybook/testing-react, the play function 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 ({ canvasElement }) => {
    const canvas = within(canvasElement);
    await userEvent.type(canvas.getByRole('textbox'), 'Hello world!');
  },
};

You can use the play function like this:

const { InputFieldFilled } = composeStories(stories);

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

  // pass container as canvasElement and play an interaction that fills the input
  await InputFieldFilled.play({ canvasElement: container });

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

@yannbf yannbf added release Create a release when this pr is merged major Increment the major version when merged labels Nov 18, 2021
@yannbf yannbf changed the title Next Version 1.0.0 Nov 22, 2021
@yannbf yannbf merged commit 87bb13b into main Nov 22, 2021
@yannbf yannbf deleted the next branch November 22, 2021 22:41
This was referenced Nov 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
major Increment the major version when merged release Create a release when this pr is merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants