Skip to content
All gists
Back to GitHub
Sign in
Sign up
Sign in
Sign up
{{ message }}
Instantly share code, notes, and snippets.
screener-io
/
Button.stories.js
Secret
Created
Sep 9, 2021
Star
0
Fork
0
Star
Code
Revisions
1
Embed
What would you like to do?
Embed
Embed this gist in your website.
Share
Copy sharable link for this gist.
Clone via HTTPS
Clone with Git or checkout with SVN using the repository’s web address.
Learn more about clone URLs
Download ZIP
3 ways to add Screener Steps to a React component in Storybook Component Story Format
Raw
Button.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
import
React
from
'react'
;
import
{
Button
}
from
'@storybook/react/demo'
;
import
Screener
,
{
Steps
}
from
'screener-storybook/src/screener'
;
export
default
{
title
:
'Button'
,
component
:
Button
,
}
;
// Add steps by wrapping component with Screener tag
export
const
ButtonState1
=
(
)
=>
<
Screener
steps
=
{
new
Steps
(
)
.
click
(
'.selector'
)
.
snapshot
(
'name'
)
.
end
(
)
}
>
<
Button
>
hello
<
/
Button
>
<
/
Screener
>
;
// Add steps by wrapping story with Screener tag in decorator
export
const
ButtonState2
=
(
)
=>
<
Button
>
hello
<
/
Button
>
;
ButtonState2
.
decorators
=
[
story
=>
<
Screener
steps
=
{
new
Steps
(
)
.
click
(
'.selector'
)
.
snapshot
(
'name'
)
.
end
(
)
}
>
{
story
(
)
}
<
/
Screener
>
]
;
// add steps without Screener tag in decorator
export
const
ButtonState3
=
(
)
=>
<
Button
>
hello
<
/
Button
>
;
ButtonState3
.
decorators
=
[
story
=>
(
{
...
story
,
steps
:
new
Steps
(
)
.
click
(
'.selector'
)
.
snapshot
(
'name'
)
.
end
(
)
}
)
]
;
Sign up for free
to join this conversation on GitHub
. Already have an account?
Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.