Skip to content

Migrate visual testing from Playwright to Storybook test-runner#333

Merged
amcdnl merged 1 commit intomasterfrom
claude/update-visual-regression-tests-p4Gwl
Mar 18, 2026
Merged

Migrate visual testing from Playwright to Storybook test-runner#333
amcdnl merged 1 commit intomasterfrom
claude/update-visual-regression-tests-p4Gwl

Conversation

@amcdnl
Copy link
Copy Markdown
Member

@amcdnl amcdnl commented Mar 17, 2026

PR Checklist

  • Tests for the changes have been added (visual tests via test-runner)
  • Docs have been added / updated

PR Type

[ ] Bugfix
[ ] Feature
[x] Code style update (formatting, local variables)
[x] Refactoring (no functional changes, no api changes)
[x] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Visual regression testing is currently implemented using Playwright with a custom story extraction script that fetches story metadata and generates snapshots.

What is the new behavior?

Visual regression testing now uses Storybook's native test-runner with jest-image-snapshot for comparison. This eliminates the need for custom story extraction and leverages Storybook's built-in testing infrastructure.

Changes Made:

  • Removed: playwright.config.ts - Playwright configuration no longer needed
  • Removed: visual-tests/visual.spec.ts - Custom Playwright test file
  • Removed: visual-tests/extract-stories.mjs - Story extraction script no longer needed
  • Added: .storybook/test-runner.ts - Storybook test-runner configuration with jest-image-snapshot integration
  • Updated: package.json scripts:
    • test:visual now uses test-storybook instead of Playwright
    • test:visual:update uses test-runner's -u flag for snapshot updates
    • Added test:visual:ci for CI environments with single worker
  • Updated: Dependencies:
    • Removed @playwright/test
    • Added @storybook/test-runner and jest-image-snapshot
  • Updated: .gitignore - Removed Playwright-specific test artifacts

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

The migration simplifies the visual testing setup by using Storybook's native test infrastructure instead of maintaining a separate Playwright configuration. The test-runner automatically discovers and tests all stories without requiring manual extraction. Animation freezing and screenshot comparison logic remain functionally equivalent.

https://claude.ai/code/session_01LyHfqq9FyNzb1JTwzd22qR

Removes the custom extract-stories.mjs script and hand-rolled Playwright
test in favour of @storybook/test-runner, which automatically discovers
every story and runs Playwright-based smoke + screenshot tests via its
postVisit hook — no custom extraction step needed.

- Add .storybook/test-runner.ts with jest-image-snapshot postVisit hook
- Replace test:visual scripts to use `test-storybook` CLI
- Remove playwright.config.ts, visual-tests/extract-stories.mjs,
  visual-tests/visual.spec.ts
- Swap @playwright/test for @storybook/test-runner + jest-image-snapshot
- Simplify .gitignore visual-tests entries

https://claude.ai/code/session_01LyHfqq9FyNzb1JTwzd22qR
Copilot AI review requested due to automatic review settings March 17, 2026 20:37
@claude
Copy link
Copy Markdown

claude bot commented Mar 17, 2026

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying reablocks-storybook with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4ae8561
Status: ✅  Deploy successful!
Preview URL: https://8130aacf.reablocks-storybook.pages.dev
Branch Preview URL: https://claude-update-visual-regress.reablocks-storybook.pages.dev

View logs

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the project’s visual regression testing approach from a custom Playwright-based harness to Storybook’s official test runner, using jest-image-snapshot for image diffs.

Changes:

  • Removed the bespoke Playwright visual test spec, story extraction script, and Playwright config.
  • Added a Storybook test-runner config that captures per-story screenshots and asserts via jest-image-snapshot.
  • Updated package.json scripts/dependencies to use test-storybook instead of playwright test.

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
visual-tests/visual.spec.ts Removed custom Playwright spec that iterated over extracted stories and asserted screenshots.
visual-tests/extract-stories.mjs Removed script that fetched Storybook index.json and generated stories.json.
playwright.config.ts Removed Playwright test runner configuration previously used for visual tests.
package.json Replaced visual test scripts with test-storybook commands; swapped dependencies to Storybook test runner + image snapshot tooling.
.storybook/test-runner.ts Added Storybook test-runner hooks to wait for readiness, freeze animations, screenshot, and diff images.
.gitignore Simplified visual testing ignores; still ignores the snapshot output directory used by the new runner.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +19 to +21
"test:visual": "test-storybook --url http://localhost:9009",
"test:visual:update": "test-storybook --url http://localhost:9009 -u",
"test:visual:ci": "test-storybook --url http://localhost:9009 --ci --maxWorkers=1",
Comment on lines +4 to +5

const customSnapshotsDir = `${process.cwd()}/visual-tests/screenshots`;
@amcdnl amcdnl merged commit 6cd4eda into master Mar 18, 2026
6 checks passed
@amcdnl amcdnl deleted the claude/update-visual-regression-tests-p4Gwl branch March 18, 2026 11:34
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