Skip to content

beforeScreenshot hook in previewjs/screenshot #1559

Answered by fwouts
KraKeN-47 asked this question in Q&A
Discussion options

You must be logged in to vote

This is now implemented in v0.1.2.

All you need is to define a function play on your story (or even on a component) which looks like this:

MyStory.play = ({ canvasElement }) => {
  // Do something with canvasElement, which is the root of the DOM.
  // See https://storybook.js.org/docs/react/writing-stories/play-function for a Storybook example
  // or directly use @testing-library/dom like https://testing-library.com/docs/dom-testing-library/example-intro
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@fwouts
Comment options

Answer selected by fwouts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants