Added Visual Regression Testing via percy.io #18797
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I've added automated Visual Regression Testing for each Storybook using percy.io.
Why
Components in a component library like
@wordpress/components
are black boxes. The consuming developer and the end-user aren't concerned what the HTML, CSS or JavaScript looks like as long as the visuals and the behaviour (including a11y) work as expected.When the markup or styles of a component change, we, consuming developers and end-users aren't concerned with what the internal change was as long as the external outcome is correct and doesn't introduce a regression. It can be very difficult from the diff of a markup or style change to assess whether a change will introduce a regression - particularly when a subtle style change can lead to significant visual changes.
How
Visual Regression Testing can be difficult to setup and troublesome to maintain (e.g. antialiasing). Therefore I've used the percy.io service which saves a lot of effort and learnings.
On CI the Percy CLI runs and uploads a screenshot of each story in the Storybook to the Percy service.
They keep a history of these images for comparison and use some secret sauce in an attempt to limit false negatives. If the visuals have significantly changed it will block the PR and require someone to review the screenshots highlighting any changes to the visuals.
Alternatives to Percy could include jest-image-snapshot.
Remaining setup
PERCY_TOKEN
to Travis as a secure environment variableHow has this been tested?
Ran
storybook:snapshot
locally, made a visual change and ranstorybook:snapshot
locally again.Screenshots
Types of changes
No external changes.
Checklist: