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

Experimenting Chromatic #22155

Open
sainthkh opened this issue May 7, 2020 · 1 comment
Open

Experimenting Chromatic #22155

sainthkh opened this issue May 7, 2020 · 1 comment
Labels
[Package] Components /packages/components Storybook Storybook and its stories for components [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Type] Discussion For issues that are high-level and not yet ready to implement.

Comments

@sainthkh
Copy link
Contributor

sainthkh commented May 7, 2020

One of the topics of Core JS meeting at May 5th was using Chromatic in Gutenberg. I signed up and tested it with my forked Gutenberg and am sharing my experience and thoughts.

How it works.

1. Setup

As it advertises, the setup process is really simple.

1. Sign up

2. Execute commands

npm install --save-dev chromatic
npx chromatic --project-token=<my-token> --build-script-name=storybook:build

We need --build-script-name option here because our build script name isn't build-storybook.

3. Wait.

Then, we can use chromatic.

2. UI and Workflow

You can see the storybook build results by builds and PRs.

build-list

pr-lists

If there are visual changes, the list is provided:

list-of-changes

And you can discuss the change on PR page. (It's impossible in discuss page.):

review-changes

3. CI and Github checks.

I've used Github actions and tested 3 cases:

As the color of the button has been changed, the status of case 1 is unfinished. The result is interesting because this change cannot be detected with storyshot because CSS code is changed. But chromatic detected it.

If there is no change in components, it simply returns pass.

And the final case solves the problem in #21485. When a component uses useInstanceId(), it changes ids when new storybook tests are added. And it breaks a lot of tests. That's why storyshot has been removed. But chromatic solves the problem. Even when the React/HTML code is changed, the visual result is the same, chromatic considers it's OK.

Pros and Cons

Pros

  • We can be sure PRs don't include unintended visual changes in components.

Cons

Things to Discuss

How should we set this up?

As mentioned above, I used Github Actions to test this. But in Github Actions, "Secrets are not passed to workflows that are triggered by a pull request from a fork." In other words, any pull requests from forked repos don't trigger Chromatic.

One of the solutions is to make the token public.

Interestingly, it is one of the recommended way of setting up CI according to the documentation. I also thought about it and it's not a bad idea, because there's nothing abusers can get with the token. They cannot use Chromatic for free because they need to approve the changes first to compare their changes but they cannot approve without joining the team.

@sainthkh sainthkh added [Package] Components /packages/components [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues. labels May 7, 2020
@gziolo
Copy link
Member

gziolo commented May 7, 2020

Awesome work exploring how we could take advantage of Chromatic ❤️

We need --build-script-name option here because our build script name isn't build-storybook.

I wasn't aware that they have a convention for it, but it seems fine as is.

Cross-linking the previous exploration percy.io that is built around Storybook as well: #18797.

@gziolo gziolo added the Storybook Storybook and its stories for components label May 7, 2020
@youknowriad youknowriad added [Type] Discussion For issues that are high-level and not yet ready to implement. and removed [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues. labels Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components Storybook Storybook and its stories for components [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Type] Discussion For issues that are high-level and not yet ready to implement.
Projects
None yet
Development

No branches or pull requests

3 participants