Chore/3399 add vitest visual testing support to components repo#3410
Chore/3399 add vitest visual testing support to components repo#3410a11ymiko wants to merge 14 commits into
Conversation
|
🕸 Preview deploys |
There was a problem hiding this comment.
Pull request overview
Adds Vitest-based visual regression testing support to the components monorepo by introducing the Chromatic Vitest integration and a first example visual spec, wired into the repo’s existing multi-project Vitest setup and Wireit scripts.
Changes:
- Adds a new
visualVitest project that runsvisual/*.visual.spec.tswith@chromatic-com/vitest’schromaticPlugin(). - Introduces Wireit scripts (
test:visual,test:visual:ci) and a sample visual spec forsl-menu-button. - Updates
yarn.lockto include the new Chromatic Vitest dependency tree.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| yarn.lock | Adds lockfile entries for @chromatic-com/vitest and transitive deps. |
| vitest.config.ts | Adds a visual Vitest project and loads chromaticPlugin(). |
| visual/menu-button.visual.spec.ts | New visual regression spec exercising the menu-button story + interactions. |
| package.json | Adds Wireit tasks for visual tests and installs @chromatic-com/vitest. |
| - name: Upload Vitest archives to Chromatic | ||
| run: yarn exec chromatic --vitest --project-token=${{ secrets.CHROMATIC_TOKEN_VISUAL }} | ||
| env: | ||
| CHROMATIC_SHA: ${{ github.sha }} | ||
| CHROMATIC_BRANCH: ${{ github.ref_name }} |
| "files": [ | ||
| ".storybook/vitest.setup.ts", | ||
| "visual/**/*.visual.spec.ts" | ||
| ] |
| "files": [ | ||
| ".storybook/vitest.setup.ts", | ||
| "visual/**/*.visual.spec.ts" | ||
| ] |
| const waitForPopoverState = async (menu: MenuElement, expectedOpen: boolean) => { | ||
| let attempts = 0; | ||
|
|
||
| while (attempts < 50) { | ||
| const isOpen = menu.matches(':popover-open'); | ||
| if (isOpen === expectedOpen) { | ||
| return; | ||
| } | ||
|
|
||
| await new Promise(resolve => requestAnimationFrame(resolve)); | ||
| attempts++; | ||
| } | ||
|
|
||
| throw new Error( | ||
| `Timed out waiting for menu popover state "${expectedOpen ? 'open' : 'closed'}".` | ||
| ); |
No description provided.