vitest icon indicating copy to clipboard operation
vitest copied to clipboard

Vitest should install correct ui/browser package versions via CLI

Open yannbf opened this issue 1 year ago • 1 comments

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: https://github.com/vitest-dev/vitest/blob/52d545bf9ccb49bba1e090bbb69cfc5228288bd5/packages/vitest/src/node/packageInstaller.ts#L43

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

yannbf avatar Jun 07 '24 08:06 yannbf

This is also an issue with code coverage packages. As we (intentionally) require all Vitest packages to be on same version, it's not guaranteed that [email protected] and @vitest/<package>@1.5.0 work together. When auto-installing prompted coverage packages while running older versions of Vitest, you may end up in a situation where newer version @vitest/coverage-* is installed.

AriPerkkio avatar Jun 07 '24 11:06 AriPerkkio