Skip to content

test(storybook): stop calling setProjectAnnotations in the addon-vitest setup file - #397

Merged
gregberge merged 1 commit into
mainfrom
fix/storybook-11-setup-file
Oct 7, 2026
Merged

gregberge merged 1 commit into
mainfrom
fix/storybook-11-setup-file

Conversation

@gregberge

Copy link
Copy Markdown
Member

Description

The e2e-storybook-next job fails. The job upgrades to the Storybook 11 pre-release, which now resolves to 11.0.0-alpha.3. That version throws SB_ADDON_VITEST_0002 (ProjectAnnotationsAlreadyAppliedError) when a setup file of an @storybook/addon-vitest project calls setProjectAnnotations(), so all 6 story suites failed on import.

Since Storybook 10.3, addon-vitest applies the project annotations itself: .storybook/preview plus the previews of the addons registered in .storybook/main. On 10.x the manual call only turned that off; 11 makes it an error. See the Storybook migration note.

Changes, all in the e2e setup of packages/storybook (no SDK code):

  • The storybook Vitest project no longer has a setup file.
  • storybook-addon-pseudo-states is registered in .storybook/main, so the addon applies its annotations. Before, they only came in through the setup file.
  • The setup file moves to vitest-sdk/portable-stories.setup.ts. Only the portable stories project still uses it, because portable stories need the call.

Type of changes

bug

Checklist

  • I have read the CONTRIBUTING doc
  • The commits message follows the Conventional Commits' policy
  • Lint and unit tests pass locally
  • I have added tests if needed (n/a: the change is to the e2e setup itself)

Optional checks:

  • My changes requires a change to the documentation
  • I have updated the documentation accordingly

Further comments

Checked locally:

  • Storybook 10.6: Vitest e2e 23/23 pass, and every screenshot and metadata file is byte-identical to main.
  • Storybook 11.0.0-alpha.3 (same pnpm up as the CI job): 23/23 pass, with the same screenshots.
  • Test-runner flow: 15/15 pass. tsc, eslint and prettier are clean.

Expect 2 changed screenshots in the test-runner Argos build: example-button--primary-hover (light and dark). The pseudo-states addon was never registered for the built Storybook, so the test-runner flow ignored the story's pseudo: { hover: true } and shot a plain button. It now renders hovered, which matches the Vitest flow.

examples/storybook-vitest/.storybook/vitest.setup.js makes the same call and will hit this error on Storybook 11. It is left for a separate change.

🤖 Generated with Claude Code

…st setup file

Storybook 11.0.0-alpha.3 throws SB_ADDON_VITEST_0002
(ProjectAnnotationsAlreadyAppliedError) when a setup file of an
`@storybook/addon-vitest` project calls `setProjectAnnotations()`: the addon
applies the project annotations itself (it has since 10.3), which broke every
story suite of the `e2e-storybook-next` job.

- Drop the setup file from the `storybook` Vitest project.
- Register `storybook-addon-pseudo-states` in `.storybook/main` so the addon
  applies its annotations.
- Move the setup file to `vitest-sdk/portable-stories.setup.ts`: only the
  portable stories project still needs the call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gregberge gregberge added the bug Something isn't working label Oct 7, 2026
@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
argos-js-sdk-reference Ready Ready Preview Oct 7, 2026 10:38am UTC

Request Review

@gregberge
gregberge merged commit bfd4137 into main Oct 7, 2026
79 checks passed
@gregberge
gregberge deleted the fix/storybook-11-setup-file branch October 7, 2026 13:07

This branch was successfully deployed

1 active deployment
Preview — 2623cea4 Deployed Oct 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant