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

test: Introduce Chromatic for visual regression tests #730

Merged
merged 6 commits into from
Jan 24, 2023

Conversation

gnapse
Copy link
Contributor

@gnapse gnapse commented Dec 27, 2022

Short description

This is work in progress, not even sure it's going to make it to main yet.

Chromatic is a visual regression testing system provided via an external service (SaaS). It is based on Storybooks (in fact, it's provided by the creators and maintainers of Storybooks). What it does is, it runs your Storybooks stories and creates screenshots of them, which are then used as the basis for comparing when new screenshots are taken in the future.

This PR integrates Chromatic with Reactist's PR builds, so that whenever a PR is created, Chromatic is run and runs the visual regression tests. Via Chromatic's UI, you can review the changes and approve or reject any visual changes that the new PR may have created. More details about this below.

Here’s a sneak peek of what we get with Chromatic:

  • Snapshot changes need to be approved

    • Checks in the CI build that come from Chromatic. If there are snapshot differences, they need to be approved in Chromatic’s UI first

      CleanShot 2023-01-20 at 20 01 24@2x
    • Once all changes are approved in Chromatic, the CI step is marked as passed

      CleanShot 2023-01-20 at 20 31 30@2x
    • If the reviewer in Chromatic does not accept all visual changes, the CI step is marked as failed instead

      CleanShot 2023-01-20 at 20 05 23@2x
  • Storybooks instance per PR

    • In all PRs, we also get a hosted Storybook instance reflecting the changes in the PR. See the link also provided in the CI checks. This will allow us to involve designers and other stakeholders in seeing changes live before merging.

Related references

Test plan

  • Expand the successful CI checks UI below to see the individual steps. See that there are some steps corresponding to Chromatic (https://share.cleanshot.com/gZ9JKqBW)
  • Open the "Details" link to the right of the CI step labelled "Storybook publish"
    • From what I understood, anyone should be able to see it, and you do not need the Chromatic account that you'll be creating in the next steps. But if that's not the case, then let me know, and leave this step for after you create the Chromatic account.
  • Create an account at https://chromatic.com, using GitHub as your authentication provider.
    • It's absolutely important that you use GitHub.
  • Check if you automatically see the Reactist project, or maybe I need to invite you to it. Don't know, as this is all new to me. Let me know. We might even sync via a video call next week if needed.
    • Maybe a good way to do this is that instead of visiting chromatic.com manually, click the "Details" link in one of the Chromatic CI steps below.

We'll take it from there once you see the project in Chromatic. This is mostly to validate that we can all use Chromatic for collaboration.

PR Checklist

  • Added tests for bugs / new features
  • Updated docs (storybooks, readme)
  • Executed npm run validate and made sure no errors / warnings were shown
  • Described changes in CHANGELOG.md

Versioning

This does not need to generate a new release, as it's all inward improvements for maintainers only. No new user-facing features are included here.

@gnapse gnapse self-assigned this Dec 27, 2022
@gnapse gnapse force-pushed the ernesto/vrt/chromatic branch from 17711ce to e4c8ec0 Compare December 27, 2022 18:13
@gnapse gnapse force-pushed the ernesto/vrt/chromatic branch from 01fadfb to d415f03 Compare December 29, 2022 14:19
@gnapse gnapse changed the base branch from main to ernesto/modal-stories December 29, 2022 14:19
@gnapse gnapse force-pushed the ernesto/vrt/chromatic branch from d415f03 to 78a6e40 Compare January 3, 2023 12:04
@gnapse gnapse force-pushed the ernesto/modal-stories branch from d2ae781 to e169144 Compare January 3, 2023 12:06
@gnapse gnapse force-pushed the ernesto/vrt/chromatic branch from 78a6e40 to 721999e Compare January 3, 2023 12:07
Base automatically changed from ernesto/modal-stories to main January 3, 2023 12:41
@gnapse gnapse force-pushed the ernesto/vrt/chromatic branch 3 times, most recently from 4759170 to 507265d Compare January 5, 2023 20:06
@gnapse gnapse force-pushed the ernesto/vrt/chromatic branch from 531e73e to 1f8d62c Compare January 20, 2023 22:51
@gnapse gnapse marked this pull request as ready for review January 20, 2023 23:30
@gnapse gnapse requested review from a team and frankieyan and removed request for a team January 20, 2023 23:35
@frankieyan
Copy link
Member

@gnapse I'm going to re-roll as I'll be off the first half of next week. Super interesting though, I'll definitely check it out when I'm back 👍

@frankieyan frankieyan requested review from a team and scottlovegrove and removed request for frankieyan and a team January 21, 2023 03:27
Copy link
Contributor

@scottlovegrove scottlovegrove left a comment

Choose a reason for hiding this comment

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

Was able to view the storybook without the chromatic account.
Was able to create a chromatic account and once in, it showed me the Reactist project. There were two there, one is Reactist the other is reactist. I think the former is the one we are really expecting, correct?

@gnapse
Copy link
Contributor Author

gnapse commented Jan 24, 2023

There were two there, one is Reactist the other is reactist. I think the former is the one we are really expecting, correct?

Yup. I had not noticed that, and do not know how that other one came into being, but I now removed it.

@gnapse gnapse merged commit 62102eb into main Jan 24, 2023
@gnapse gnapse deleted the ernesto/vrt/chromatic branch January 24, 2023 14:41
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.

3 participants