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

chore: component visual regression tests using percy #166

Merged
merged 8 commits into from
Dec 12, 2022

Conversation

Ashley-p44
Copy link
Contributor

@Ashley-p44 Ashley-p44 commented Dec 1, 2022

Closes #DES-381

📝 Description

Percy

Added Percy SDK for Storybook and Percy's CLI.

I ultimately decided this was a way better solution than Cypress + Percy plugin just due to Storybook rendering components within an iframe. TLDR: Cypress does not play nice with iframes. It's very hard to work with the elements in inside iframes and they usually do not show up in test failure snapshots (at least with Cypress).

I found the the documentation for Percy Storybook SDK and it is super straight forward and covers all test cases I think we are interested in. If you want additional snapshots for a particular state of a component, just add a new stories in Storybook.

CI/CD

  • Added the Mainfest PERCY_TOKEN to project secrets
  • I added running visual regression tests under CI (this may not be ideal)
    • @bclark-p44 let me know your opinion, we can likely make this a little more deterministic (maybe only run if there is updates in packages or any .stories.tsx files)

Screenshots

image

Example Percy build: https://percy.io/7dd77246/Manifest/builds/23346035

Merge checklist

  • Added/updated tests
  • Added changeset

@Ashley-p44 Ashley-p44 requested a review from bclark-p44 December 1, 2022 02:06
@Ashley-p44 Ashley-p44 requested a review from a team as a code owner December 1, 2022 02:06
version: 2
snapshot:
widths:
- 1280
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bclark-p44 I limited this to one width to save on screenshots. We can easily add 375px to cover mobile.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we will be adding our adaptive sizes to the design system soon.

@@ -14,7 +14,7 @@ export default {
};

const Template: ComponentStory<typeof Tooltip> = (args) => (
<Tooltip {...args} title="Tooltip">
<Tooltip defaultOpen {...args} title="Tooltip">
Copy link
Contributor Author

@Ashley-p44 Ashley-p44 Dec 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added defaultOpen so tooltip would be present when snapshot was taken.

@Ashley-p44 Ashley-p44 changed the title [DES-381] Component Visual Regression test with Percy chore: component visual regression tests using percy Dec 1, 2022
@@ -5,7 +5,9 @@
"scripts": {
"build": "build-storybook -c .storybook -o ./build",
"dev": "start-storybook -p 6006 --quiet",
"clean": "rm -rf .turbo node_modules build"
"clean": "rm -rf .turbo node_modules build",
"percy": "percy storybook ./build",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Runs against static Storybook build instead of local or live Storybook URL

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we hoist this command to the root? would make the calling the script easier.

package.json Outdated
"prepare": "husky install",
"release-packages": "yarn build && yarn changeset publish",
"storybook:build": "yarn ./apps/storybook/ exec build-storybook -c .storybook -o ./build",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should just be able to use a filter with turbo to run this command

yarn turbo run build --filter=@project44-manifest/storybook

@Ashley-p44
Copy link
Contributor Author

@bclark-p44 looks like we ran out of Percy snapshots 😭

@Ashley-p44
Copy link
Contributor Author

Got approval from @bclark-p44 it was okay to merge. CI/CD will fail until snapshots renew in January.

@Ashley-p44 Ashley-p44 merged commit c69dc25 into main Dec 12, 2022
@Ashley-p44 Ashley-p44 deleted the DES-381-AddVisualRegressionTests branch December 12, 2022 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants