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.
Issue: N/A
What Changed
Checklist
Check the ones applicable to your change:
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 acomponent
property: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
, theplay
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:
You can use the play function like this: