Skip to content

test: run Storybook stories as Vitest browser tests#423

Open
ryanmagoon wants to merge 3 commits into
mainfrom
test/storybook-vitest-addon
Open

test: run Storybook stories as Vitest browser tests#423
ryanmagoon wants to merge 3 commits into
mainfrom
test/storybook-vitest-addon

Conversation

@ryanmagoon

Copy link
Copy Markdown
Owner

Closes #422

What

Adds @storybook/addon-vitest to packages/ui so every story runs as a component test in Vitest browser mode (headless Chromium via Playwright):

  • Every story is now a render smoke test — 134 new story tests covering all 16 story files, including the 10 storied components that previously had no test file at all (GameLibrary, GameDetails, CheatPanel, DiscSwapOverlay, ResumeGameDialog, SystemDisambiguationDialog, CoreDownloadBanner, card/dialog/alert-dialog).
  • play functions are now blocking CI assertions — previously they only ran when a story was viewed manually or incidentally inside Chromatic (which is non-blocking).
  • Existing happy-dom unit tests are unchanged, running as a separate unit Vitest project.

pnpm --filter @gamelord/ui test now runs both projects: 418 tests, 37 files, ~6s.

Supporting changes

  • Storybook 10.4/10.2 → 10.5 — the addon requires matching core exports (storybook/internal/channels).
  • Vitest 4.0 → 4.1 workspace-wide@vitest/browser-playwright requires it.
  • pnpm dedupe react react-dom — the dependency re-resolution had split the graph into react 19.1/19.2 with a nested react-dom under @testing-library/react, which broke hooks in unit tests.
  • Agentation toolbar skipped under Vitest — it fetched its session endpoint on every story mount, logging a warning per test. Storybook dev and Chromatic are unchanged.
  • CI installs Playwright Chromium before the test job.

Verification

  • Full suite green locally (418/418) both directly and under turbo.
  • Failure propagation verified empirically: mid-setup, broken story runs failed the suite loudly (version-skew import errors, duplicate-React hook crashes) — a story that throws during render fails pnpm test.
  • pnpm lint, pnpm typecheck, pnpm format:check all pass.

No screenshots — test/CI infrastructure only, no visual changes.

🤖 Generated with Claude Code

ryanmagoon and others added 3 commits July 12, 2026 00:17
…don-vitest

Adds @storybook/addon-vitest with Playwright Chromium browser mode as a
second Vitest project in packages/ui. Every story now runs as a render
smoke test and play functions execute as blocking assertions (418 tests,
134 from stories).

Version alignments required by the addon:
- storybook packages 10.4/10.2 -> 10.5 (addon needs matching core exports)
- vitest 4.0 -> 4.1 workspace-wide (@vitest/browser-playwright requires it)
- pnpm dedupe react/react-dom (re-resolution split the graph into 19.1/19.2,
  breaking hooks in unit tests with a nested react-dom copy)

Closes #422

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The toolbar fetches its session endpoint on every story mount, which
logged a warning per test in CI. Storybook dev and Chromatic rendering
are unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Story tests run in Vitest browser mode and need the browser binary on
the runner.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
gamelord-desktop Ignored Ignored Jul 12, 2026 4:17am

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.

Run Storybook stories as component tests via @storybook/addon-vitest

1 participant