Skip to content

Vitest should install correct ui/browser package versions via CLI #5855

@yannbf

Description

@yannbf

Describe the bug

When running tests with specific flags which the project is not ready for, e.g. --ui or --browser, the CLI detects the need to install such dependencies:

image

However, the dependencies don't follow the version of the CLI. In my project, I'm using vitest: 2.0.0-beta.9 and when prompted to install @vitest/browser, I end up getting latest (1.6.0). This causes further issues as the packages won't play nicely if they differ in versions, especially major versions.

It would be nice if the code which installs dependencies, if such dependencies are vitest ones e.g. @vitest/browser or @vitest/ui, that they use the same version of the installed Vitest CLI:

await (await import('@antfu/install-pkg')).installPackage(dependency, { dev: true })

Reproduction

  • Create any vitest project using a specific, non-latest version
  • Run vitest --browser
  • Get prompted, see the installed version being different than the Vitest CLI

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2-nice-to-haveNot breaking anything but nice to have (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions