Skip to content

Conversation

@jonniebigodes
Copy link
Contributor

@jonniebigodes jonniebigodes commented Oct 26, 2025

Follows up on #32819

What I did

With this pull request, the Vitest documentation was updated to reflect the recent changes regarding browser mode, configuration, etc., introduced with the Vitest 4 release.

What was done:

  • Slight adjustments to the documentation
  • Fixed existing examples
  • Created the required examples to account for the changes with Vitest 4

@yannbf can you take a glance at this and let me know of any feedback you may have? Thanks in advance

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Documentation
    • Added web‑components examples and expanded framework/language variants for Storybook + Vitest.
    • Corrected code block languages for React, Svelte, and Vue snippets.
    • Expanded Vitest v3/v4 examples with browser/Playwright variants, tab metadata, and tagging configuration examples.
    • Added examples showing Storybook URL from an environment variable and moved inline examples to external snippets.
    • Restructured CSF3 tag examples across frameworks; minor import formatting fixes.

@jonniebigodes jonniebigodes requested a review from yannbf October 26, 2025 18:06
@jonniebigodes jonniebigodes self-assigned this Oct 26, 2025
@jonniebigodes jonniebigodes added documentation ci:docs Run the CI jobs for documentation checks only. addon: vitest labels Oct 26, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 26, 2025

📝 Walkthrough

Walkthrough

Documentation-only changes: adjust code-fence languages, add a web-components addon-vitest snippet, expand and mirror Vitest 3/4 config examples (including Playwright/browser and tag options), replace inline examples with snippet references, and apply minor import formatting fixes across snippets and docs.

Changes

Cohort / File(s) Summary
Vitest plugin snippets
docs/_snippets/vitest-plugin-vitest-config.md, docs/_snippets/vitest-plugin-vitest-debug-option-ci.md, docs/_snippets/vitest-plugin-vitest-tags-configuration.md, docs/_snippets/vitest-plugin-vitest-workspace.md
Add Vitest 4 examples alongside Vitest 3 variants for React/Vue/Svelte/Web Components; add tabTitle metadata, Playwright/browser project examples, storybookTest config (configDir/storybookScript/SB_URL), setupFiles and path/dirname utilities; add tag include/exclude snippets.
Addon Vitest & CSF tag snippets
docs/_snippets/addon-vitest-set-project-annotations-simple.md, docs/_snippets/tags-remove-in-story.md
Change code-fence language from tsx to ts for multiple framework snippets; add a web-components /.storybook/vitest.setup.ts example for setProjectAnnotations; remove some older CSF3 examples and add expanded per-framework/language CSF3 tag override examples.
Import formatting snippet
docs/_snippets/vite-includeStorybookNextjsPlugin.md
Stylistic formatting: convert imports to single quotes and add missing semicolons in snippet examples.
Docs pages referencing snippets & guidance
docs/writing-tests/in-ci.mdx, docs/writing-tests/integrations/vitest-addon.mdx
Replace inline Vitest CI/workspace example with external snippet reference; update guidance to prefer separate test projects for Vitest ≥4 and workspace files for Vitest 3.x; update links and wording accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review focus:
    • Verify snippet reference paths used by in-ci.mdx and vitest-addon.mdx.
    • Ensure consistency between Vitest v3 vs v4 examples (projects vs workspace) and storybookTest options.
    • Check added web-components snippet and language tag corrections for accurate renderer labels and filenames.

Possibly related PRs

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs_adjust_vitest_addon

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 14edc9f and 3318f65.

📒 Files selected for processing (1)
  • docs/_snippets/vitest-plugin-vitest-config.md (6 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
docs/**

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Update documentation under docs/ for significant changes, including migration guides for breaking changes

Files:

  • docs/_snippets/vitest-plugin-vitest-config.md
🧠 Learnings (2)
📚 Learning: 2025-10-13T13:33:14.659Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-13T13:33:14.659Z
Learning: Applies to test-storybooks/** : Maintain test Storybook configurations under `test-storybooks/` for E2E and visual testing scenarios

Applied to files:

  • docs/_snippets/vitest-plugin-vitest-config.md
📚 Learning: 2025-09-17T08:11:04.287Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursorrules:0-0
Timestamp: 2025-09-17T08:11:04.287Z
Learning: Applies to code/vitest.workspace.ts : Keep and use the Vitest workspace configuration at code/vitest.workspace.ts

Applied to files:

  • docs/_snippets/vitest-plugin-vitest-config.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (4)
docs/_snippets/vitest-plugin-vitest-config.md (4)

1-48: Provider API consistency across Vitest versions is clear.

The React examples properly differentiate between Vitest 4's playwright({}) function-based provider (line 37) and Vitest 3's string-based 'playwright' (line 85), with corresponding import differences. This is correct and well-structured.

Also applies to: 50-96


27-28: --no-open flag change properly applied across all variants.

The update from the previous --ci approach to --no-open (addressing yannbf's feedback) has been consistently applied across all 8 configuration blocks with corresponding comment documentation. This prevents automatic browser opening when running Storybook.

Also applies to: 75-76, 124-125, 172-173, 221-222, 269-270, 318-319, 366-367


292-339: Web Components variant appropriately added with consistent patterns.

The new Web Components renderer variant mirrors the React, Vue, and Svelte patterns, with both Vitest 4 and Vitest 3 configurations showing identical structure and import handling as other renderers.

Also applies to: 341-387


1-387: Consider documenting version transition guidance in accompanying prose.

The snippet file now contains comprehensive Vitest 3 and 4 examples, but readers may not immediately understand why the Vitest 4 blocks require the @vitest/browser-playwright import while Vitest 3 doesn't. Verify that the referencing documentation (likely integrations/vitest-addon.mdx) clearly explains this API evolution and guides users on which version to adopt.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d075427 and 0f79841.

📒 Files selected for processing (9)
  • docs/_snippets/addon-vitest-set-project-annotations-simple.md (1 hunks)
  • docs/_snippets/tags-remove-in-story.md (0 hunks)
  • docs/_snippets/vite-includeStorybookNextjsPlugin.md (1 hunks)
  • docs/_snippets/vitest-plugin-vitest-config.md (3 hunks)
  • docs/_snippets/vitest-plugin-vitest-debug-option-ci.md (1 hunks)
  • docs/_snippets/vitest-plugin-vitest-tags-configuration.md (1 hunks)
  • docs/_snippets/vitest-plugin-vitest-workspace.md (1 hunks)
  • docs/writing-tests/in-ci.mdx (1 hunks)
  • docs/writing-tests/integrations/vitest-addon.mdx (4 hunks)
💤 Files with no reviewable changes (1)
  • docs/_snippets/tags-remove-in-story.md
🧰 Additional context used
📓 Path-based instructions (1)
docs/**

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Update documentation under docs/ for significant changes, including migration guides for breaking changes

Files:

  • docs/_snippets/vitest-plugin-vitest-debug-option-ci.md
  • docs/_snippets/vite-includeStorybookNextjsPlugin.md
  • docs/writing-tests/integrations/vitest-addon.mdx
  • docs/_snippets/addon-vitest-set-project-annotations-simple.md
  • docs/_snippets/vitest-plugin-vitest-config.md
  • docs/_snippets/vitest-plugin-vitest-tags-configuration.md
  • docs/writing-tests/in-ci.mdx
  • docs/_snippets/vitest-plugin-vitest-workspace.md
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: storybookjs/storybook#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-13T13:33:14.659Z
Learning: Applies to test-storybooks/** : Maintain test Storybook configurations under `test-storybooks/` for E2E and visual testing scenarios
📚 Learning: 2025-09-17T08:11:04.287Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursorrules:0-0
Timestamp: 2025-09-17T08:11:04.287Z
Learning: Applies to code/vitest.workspace.ts : Keep and use the Vitest workspace configuration at code/vitest.workspace.ts

Applied to files:

  • docs/_snippets/vitest-plugin-vitest-debug-option-ci.md
  • docs/writing-tests/integrations/vitest-addon.mdx
  • docs/_snippets/vitest-plugin-vitest-config.md
  • docs/_snippets/vitest-plugin-vitest-tags-configuration.md
  • docs/_snippets/vitest-plugin-vitest-workspace.md
📚 Learning: 2025-10-13T13:33:14.659Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-13T13:33:14.659Z
Learning: Applies to test-storybooks/** : Maintain test Storybook configurations under `test-storybooks/` for E2E and visual testing scenarios

Applied to files:

  • docs/_snippets/vitest-plugin-vitest-debug-option-ci.md
  • docs/writing-tests/integrations/vitest-addon.mdx
  • docs/_snippets/vitest-plugin-vitest-config.md
  • docs/_snippets/vitest-plugin-vitest-tags-configuration.md
  • docs/writing-tests/in-ci.mdx
  • docs/_snippets/vitest-plugin-vitest-workspace.md
🪛 LanguageTool
docs/_snippets/vitest-plugin-vitest-debug-option-ci.md

[grammar] ~1-~1: Hier könnte ein Fehler sein.
Context: ts filename="vitest.config.ts" renderer="common" tabTitle="Vitest 4" export default defineConfig({ // ... test: { // ... projects: [ { plugins: [ storybookTest({ // ... // 👇 Use the environment variable you passed storybookUrl: process.env.SB_URL, }), ], }, ], }, }); ts filename="vitest.workspace.ts" renderer="common" tabTitle="Vitest 3" export default defineWorkspace([ // ... { // ... { plugins: [ storybookTest({ // ... // 👇 Use the environment variable you passed storybookUrl: process.env.SB_URL }), ], }, }, ]);

(QB_NEW_DE)

docs/_snippets/addon-vitest-set-project-annotations-simple.md

[grammar] ~1-~1: Hier könnte ein Fehler sein.
Context: ts filename=".storybook/vitest.setup.ts" renderer="react" language="ts" // Replace your-framework with the framework you are using, e.g. react-vite, nextjs, nextjs-vite, etc. import { setProjectAnnotations } from '@storybook/your-framework'; import * as previewAnnotations from './preview'; const annotations = setProjectAnnotations([previewAnnotations]); ts filename=".storybook/vitest.setup.ts" renderer="svelte" language="ts" // Replace your-framework with the framework you are using, e.g. sveltekit or svelte-vite import { setProjectAnnotations } from '@storybook/your-framework'; import * as previewAnnotations from './preview'; const annotations = setProjectAnnotations([previewAnnotations]); ts filename=".storybook/vitest.setup.ts" renderer="vue" language="ts" import { setProjectAnnotations } from '@storybook/vue3-vite'; import * as previewAnnotations from './preview'; const annotations = setProjectAnnotations([previewAnnotations]); ts filename=".storybook/vitest.setup.ts" renderer="web-components" language="ts" import { setProjectAnnotations } from '@storybook/web-components-vite'; import * as previewAnnotations from './preview'; const annotations = setProjectAnnotations([previewAnnotations]);

(QB_NEW_DE)

docs/_snippets/vitest-plugin-vitest-tags-configuration.md

[grammar] ~1-~1: Hier könnte ein Fehler sein.
Context: ts filename="vitest.config.ts" renderer="common" tabTitle="Vitest 4" export default defineConfig({ // ... test: { // ... projects: [ { plugins: [ storybookTest({ // ... tags: { include: ['test'], exclude: ['experimental'], }, }), ], // ... }, ], }, }); ts filename="vitest.workspace.ts" renderer="common" tabTitle="Vitest 3" export default defineWorkspace([ // ... { // ... { plugins: [ storybookTest({ // ... tags: { include: ['test'], exclude: ['experimental'], }, }), ], }, }, ]);

(QB_NEW_DE)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (12)
docs/_snippets/vite-includeStorybookNextjsPlugin.md (1)

2-3: Minor formatting improvement: consistent quote and semicolon style.

Updated import statements to use single quotes and added trailing semicolons for consistency with common TypeScript/JavaScript conventions in the documentation examples.

docs/_snippets/addon-vitest-set-project-annotations-simple.md (1)

1-29: LGTM! Consistent framework documentation with web-components support.

Updated language fencing for consistency and added web-components renderer support with the correct import path (@storybook/web-components-vite). All setProjectAnnotations examples now follow a uniform pattern across React, Svelte, Vue, and Web Components renderers.

docs/_snippets/vitest-plugin-vitest-workspace.md (1)

122-161: LGTM! Web-components renderer support added consistently.

Added web-components workspace configuration following the same pattern as React, Vue, and Svelte variants. The browser configuration (Playwright provider, headless mode, Chromium instance) and setupFiles reference are correctly applied.

docs/writing-tests/in-ci.mdx (1)

334-338: LGTM! Proper external snippet reference with formatting guards.

Replaced inline code example with a clean <CodeSnippets> reference to the external snippet at vitest-plugin-vitest-debug-option-ci.md. The prettier-ignore directives correctly prevent formatter interference, maintaining documentation layout integrity.

Verify that the referenced snippet file path vitest-plugin-vitest-debug-option-ci.md resolves correctly from the docs structure (should map to docs/_snippets/vitest-plugin-vitest-debug-option-ci.md).

docs/writing-tests/integrations/vitest-addon.mdx (4)

66-66: LGTM! Clear version-specific guidance for test configuration.

Added explicit guidance distinguishing between Vitest ≥ 4.0 (use separate test project) and Vitest 3.x (use workspace file). This helps users select the correct configuration pattern for their environment.


100-102: Good documentation version clarity.

Updated example header to clarify this applies to Vitest < 3.2, and link now points to v3-specific documentation. Helps users navigate to the version-appropriate reference material.


227-231: LGTM! Proper external snippet reference for tags configuration.

Replaced inline configuration block with <CodeSnippets> reference to vitest-plugin-vitest-tags-configuration.md. The formatter-ignore guards ensure layout consistency. This centralized example ensures both Vitest 4 and 3 variants are shown.

Verify that vitest-plugin-vitest-tags-configuration.md correctly displays both Vitest 4 and Vitest 3 configuration variants as expected by users reading this section.


298-298: LGTM! Consistent version guidance in FAQ section.

Reiterated version-specific guidance (test project vs workspace) in the FAQ, reinforcing the pattern across the documentation.

docs/_snippets/vitest-plugin-vitest-config.md (4)

1-96: LGTM! React examples show correct Vitest 4/3 configuration patterns.

Both Vitest 4 and 3 React examples correctly demonstrate version-specific differences:

  • Vitest 4 (line 3): imports playwright from @vitest/browser-playwright, uses provider: playwright({})
  • Vitest 3 (line 85): uses provider: 'playwright' as string literal

Configuration structure, plugins, and setupFiles are consistent and properly configured.


98-192: LGTM! Vue examples mirror React pattern with correct version handling.

Vue configuration examples (Vitest 4 and 3) follow the established pattern with consistent provider configuration differences between versions. Framework-specific imports and configuration are accurate.


195-289: LGTM! Svelte examples maintain consistent framework support.

Svelte Vitest 4 and 3 examples follow the version-specific pattern established across React and Vue, providing complete framework coverage with appropriate provider configuration for each Vitest version.


292-386: LGTM! Web-components renderer coverage completed across both Vitest versions.

Added web-components renderer support for both Vitest 4 and 3, maintaining consistency with React, Vue, and Svelte examples. The provider configuration correctly follows the Vitest version-specific pattern (function call vs string literal).

@nx-cloud
Copy link

nx-cloud bot commented Oct 26, 2025

View your CI Pipeline Execution ↗ for commit 3318f65

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 1m 5s View ↗

☁️ Nx Cloud last updated this comment at 2025-10-28 09:15:11 UTC

configDir: path.join(dirname, '.storybook'),
// This should match your package.json script to run Storybook
// The --ci flag will skip prompts and not open a browser
storybookScript: 'yarn storybook --ci',
Copy link
Member

Choose a reason for hiding this comment

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

I think we should change this to --no-open instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no objections to it.

Copy link
Member

@yannbf yannbf left a comment

Choose a reason for hiding this comment

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

LGTM, thanks a lot @jonniebigodes !!

@yannbf yannbf added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Oct 28, 2025
@yannbf yannbf merged commit ee7ce39 into next Oct 28, 2025
12 of 14 checks passed
@yannbf yannbf deleted the docs_adjust_vitest_addon branch October 28, 2025 09:15
yannbf added a commit that referenced this pull request Oct 28, 2025
Docs: Vitest plugin adjustments
(cherry picked from commit ee7ce39)
@github-actions github-actions bot mentioned this pull request Oct 28, 2025
8 tasks
@github-actions github-actions bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Oct 28, 2025
@ndelangen ndelangen removed the patch:yes Bugfix & documentation PR that need to be picked to main branch label Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addon: vitest ci:docs Run the CI jobs for documentation checks only. documentation patch:done Patch/release PRs already cherry-picked to main/release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants