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

Commit d6a0cfe

Browse files
committed
docs: add CSF3 requirements section
1 parent 212aa9c commit d6a0cfe

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,30 @@ Primary.args!.children;
158158

159159
### CSF3
160160

161-
Storybook released a [new version of CSF](https://storybook.js.org/blog/component-story-format-3-0/), where the story can also be an object. This is supported in @storybook/testing-react _if you're using Storybook 6.4 or higher_. CSF3 also brings a new function called `play`, where you can write automated interactions to the story.
161+
Storybook released a [new version of CSF](https://storybook.js.org/blog/component-story-format-3-0/), where the story can also be an object. This is supported in @storybook/testing-react, but you have to match the requisites:
162162

163-
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.
163+
1 - Either your **story** has a `render` method or your **meta** contains a `component` property:
164+
165+
```js
166+
// Example 1: Meta with component property
167+
export default {
168+
title: 'Button',
169+
component: Button // <-- This is strictly necessary
170+
}
171+
172+
// Example 2: Story with render method:
173+
export const Primary = {
174+
render: (args) => <Button {...args}>
175+
}
176+
```
177+
178+
2 - For typescript users, you need to be using Storybook 6.4 or higher.
179+
180+
#### CSF3 - Interactions with play function
181+
182+
CSF3 also brings a new function called `play`, where you can write automated interactions to the story.
183+
184+
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.
164185

165186
Consider the following example:
166187

0 commit comments

Comments
 (0)