Skip to content

Vitest: Fallback detecting vitest version in postinstall#33415

Merged
ndelangen merged 3 commits into
nextfrom
norbert/vitest-version-detection-fallback
Dec 24, 2025
Merged

Vitest: Fallback detecting vitest version in postinstall#33415
ndelangen merged 3 commits into
nextfrom
norbert/vitest-version-detection-fallback

Conversation

@ndelangen
Copy link
Copy Markdown
Member

@ndelangen ndelangen commented Dec 23, 2025

Closes #33410

What I did

I copied the fallback mechanism found in AddonVitestService to the postinstall. Though this is no longer really needed due to the second fix in this PR:

I have figured out why the packageManager.getInstalledVersion('vitest') is failing:

When this command is executed:

pnpm list "vitest" --json --depth=99

pnpm exits with code=1, with this error:

"code": "EINVALIDTAGNAME",
"message": "Invalid tag name \"\"vitest\"\": Tags may not have any characters that encodeURIComponent encodes."

Running the command with shell:true resolves the problem.

It seemed both pnpm and yarn1 PackageManager-instances were affected by this.

I've added additional debug logging to make the errors easier to find in the future.

Another discovery was that the config-file getting edited/generated for addon-vitest can get out of sync with the version getting add/installed due to a missing semver.coerce.

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

I've tested a canary with just the fallback addition.

Then I switched to running the bin directly off a development branch, as suggested by the issue.
Adding debug logging until I was able to figure out why the installed version was not correctly detected.

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 pull request has been released as version 0.0.0-pr-33415-sha-8542def9. Try it out in a new sandbox by running npx storybook@0.0.0-pr-33415-sha-8542def9 sandbox or in an existing project with npx storybook@0.0.0-pr-33415-sha-8542def9 upgrade.

More information
Published version 0.0.0-pr-33415-sha-8542def9
Triggered by @ndelangen
Repository storybookjs/storybook
Branch norbert/vitest-version-detection-fallback
Commit 8542def9
Datetime Tue Dec 23 10:58:13 UTC 2025 (1766487493)
Workflow run 20458859104

To request a new release of this pull request, mention the @storybookjs/core team.

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Dec 23, 2025

View your CI Pipeline Execution ↗ for commit b83b026

Command Status Duration Result
nx run-many -t compile,check,knip,test,pretty-d... ✅ Succeeded 10m 8s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-23 14:30:06 UTC

@storybook-app-bot
Copy link
Copy Markdown

storybook-app-bot Bot commented Dec 23, 2025

Package Benchmarks

Commit: b83b026, ran on 23 December 2025 at 14:30:43 UTC

The following packages have significant changes to their size or dependencies:

@storybook/builder-webpack5

Before After Difference
Dependency count 192 192 0
Self size 75 KB 75 KB 🎉 -48 B 🎉
Dependency size 32.17 MB 32.21 MB 🚨 +38 KB 🚨
Bundle Size Analyzer Link Link

@storybook/ember

Before After Difference
Dependency count 196 196 0
Self size 15 KB 15 KB 🎉 -18 B 🎉
Dependency size 28.89 MB 28.93 MB 🚨 +38 KB 🚨
Bundle Size Analyzer Link Link

@storybook/nextjs

Before After Difference
Dependency count 538 538 0
Self size 646 KB 646 KB 🚨 +120 B 🚨
Dependency size 59.11 MB 59.15 MB 🚨 +38 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-webpack5

Before After Difference
Dependency count 278 278 0
Self size 24 KB 24 KB 🚨 +12 B 🚨
Dependency size 44.06 MB 44.10 MB 🚨 +38 KB 🚨
Bundle Size Analyzer Link Link

@storybook/server-webpack5

Before After Difference
Dependency count 204 204 0
Self size 16 KB 16 KB 0 B
Dependency size 33.43 MB 33.47 MB 🚨 +38 KB 🚨
Bundle Size Analyzer Link Link

@storybook/preset-react-webpack

Before After Difference
Dependency count 170 170 0
Self size 18 KB 18 KB 🎉 -24 B 🎉
Dependency size 31.20 MB 31.24 MB 🚨 +38 KB 🚨
Bundle Size Analyzer Link Link

Copy link
Copy Markdown
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!

@ndelangen ndelangen merged commit 2a7ae11 into next Dec 24, 2025
69 checks passed
@ndelangen ndelangen deleted the norbert/vitest-version-detection-fallback branch December 24, 2025 17:56
@github-actions github-actions Bot mentioned this pull request Dec 24, 2025
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: In some Vitest 3 projects, Addon Vitest is set up with a Vitest 4 config instead

2 participants