Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setPreRender/setPostRender hooks & example #38

Merged
merged 10 commits into from
Feb 3, 2022
Merged

Add setPreRender/setPostRender hooks & example #38

merged 10 commits into from
Feb 3, 2022

Conversation

shilman
Copy link
Member

@shilman shilman commented Feb 3, 2022

What I did

  • Added test lifecycle hooks
  • Added image snapshotting example & snapshots
  • Added initial documentation
  • Aligned stories.json/CSF mode behavior
setPostRender(async (page, context) => {
  const image = await page.screenshot();
  expect(image).toMatchImageSnapshot({
    customSnapshotsDir,
    customSnapshotIdentifier: context.id,
  });
});

How to test

yarn build
yarn test-storybook:playwright
# edit a component story
yarn test-storybook:playwright
📦 Published PR as canary version: 0.0.2-canary.38.ad367be.0

✨ Test out this PR locally via:

npm install @storybook/test-runner@0.0.2-canary.38.ad367be.0
# or 
yarn add @storybook/test-runner@0.0.2-canary.38.ad367be.0

Version

Published prerelease version: v0.0.2-next.7

Changelog

🐛 Bug Fix

⚠️ Pushed to next

📝 Documentation

  • docs(README): add section about jest #29 (@yannbf)

Authors: 2

@shilman shilman added the feature request New feature or request label Feb 3, 2022
@shilman shilman requested a review from yannbf February 3, 2022 08:29
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/csf/transformCsf.ts Outdated Show resolved Hide resolved
@p01
Copy link

p01 commented Feb 3, 2022

Any chance to extend userEvent from @storybook/testing-library to enable to take screenshots throughout the play function, and not just as a preRender/postRender hook ? Or do you see this as something out of scope for the default feature set of Storybook/test-runner ?

This is something we have built into Storywright ( this is mostly used internally and haven't focused on public docs so far ) but I am very happy to see Storybook/test-runner and would rather work together on a solution that works for the broader community.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@shilman
Copy link
Member Author

shilman commented Feb 3, 2022

@p01 Thanks for reaching out and very nice to meet you! Storywright looks really cool--it's the first time I'm seeing it. I'd love to learn more about where you're going with it, talk through what we're aiming for with the test runner, and figure out how we might collaborate. Any interest in doing a call in the next couple weeks?

README.md Outdated Show resolved Hide resolved
@yannbf yannbf merged commit 52c0571 into next Feb 3, 2022
@yannbf yannbf mentioned this pull request Feb 3, 2022
@yannbf yannbf deleted the test-hooks branch August 23, 2022 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants