-
Notifications
You must be signed in to change notification settings - Fork 534
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(project): add vrt and avt tests through playwright #2491
Conversation
|
size-limit report 📦
|
Nice 👍🏻 Maybe we could work together to set this up for view_components next time we pair? |
Have you considered using Storybook interactions for this? Example of interaction, Example of snaphot.
What about running these in an Actions runner instead? Generating the snapshots locally-only may limit future contributions and snapshot regeneration to folks in darwin environment (or worse, create duplicates). Ideally you'd do it in a containerised environment, which you can run locally or on the server. That'll generate filenames with the
I recommend self-generating spec files with blanket coverage so you can just run and forget about them. Where you need granular control over some part of the config, like providing timeouts, different viewports, etc.. you can do that in the generation script. Here's a basic example, but can be done in many other ways too. |
I would prioritize snapshotting everything within a component's
I like that everything lives "in house" and can be seen in GitHub (like the actual screenshots). As someone who doesn't contribute to PRC regularly, I don't really know how to access or use Chromatic.
I think auto-generated based on that features directory.. it might be interesting if a story author could opt in a specific story, thinking maybe a more detailed one from the |
Thanks everyone for the feedback! 🙏 I took the suggestions from this PR and created a smaller, more focused one for |
Overview
This PR is an exploration into using Playwright for VRT (Visual Regression Testing) and AVT (Accessibility Verification Testing).
Tests are currently located in the
e2e
directory and were generated from Storybook stories. Each test has roughly the following structure:Currently, the snapshots only run against Chromium with the default browser width. There is the ability to extend snapshots per-browser, if needed, and per-breakpoint.
Developer Experience
A developer can run tests with Playwright using:
npx playwright test
. They can also filter tests by test name:npx playwright test ActionList
or by groups that are listed in the test name:npx playwright test --grep vrt
Reports of a test run are included both in the terminal and in an HTML report that can be opened and interacted with.
Terminal
HTML
A screenshot can be made by using
expect(await page.screenshot()).toMatchSnapshot()
. A page can be checked for axe violations by writingawait expect(page).toHaveNoViolations()
In addition, developers may use the VSCode extension to interact with Playwright: https://playwright.dev/docs/getting-started-vscode
CI
This experiment adds in two separate jobs:
vrt
andavt
. Each job uses Playwright's--grep
option to only test for the specific tests that have that tag.In order to speed up VRT tests, we make use of a
vrt-runner
job that uses a matrix strategy to create multiple runners that each run a portion of our tests. These runners rollup into thevrt
job described above which will report the status of each runnerDrawbacks
Questions
Notes
e2e
, instead we could have a convention likeComponentName.visual.test.ts
that lives beside the component (and is ignored by Jest)