vitest-dev / vscode

VS Code extension for Vitest
https://vitest.dev/vscode
MIT License
740 stars 83 forks source link

v0.5.0 failing to activate in a monorepo with vitest.workspace.ts and per-package vite.config.ts #292

Open chriswheeldon-peakon opened 6 months ago

chriswheeldon-peakon commented 6 months ago

Describe the bug

I was curious to try it out the new pre-release version with https://github.com/chriswheeldon-peakon/vitest-workspace-cwd but the extension fails to load with:

2024-03-15 14:27:52.495 [error] Activating extension vitest.explorer failed due to an error:
2024-03-15 14:27:52.495 [error] Error: Attempted to insert a duplicate test item ID /Users/jbloggs/code/vitest-workspaces
    at Object.replace (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:138:24636)
    at Ge.reset (/Users/jbloggs/.vscode/extensions/vitest.explorer-0.5.0/dist/extension.js:7:1888)
    at Tt.defineTestProfiles (/Users/jbloggs/.vscode/extensions/vitest.explorer-0.5.0/dist/extension.js:7:5932)
    at async Tt.activate (/Users/jbloggs/.vscode/extensions/vitest.explorer-0.5.0/dist/extension.js:7:7329)
        ...

This is a monorepo with multiple vite.config.ts files (one in each package) and a vitest.workspace.ts in the repo root.

Reproduction

https://github.com/chriswheeldon-peakon/vitest-workspace-cwd

System Info

System:
    OS: macOS 14.3.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 29.92 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - /var/folders/sb/jdkc4cv91zvgvvzwhq9lyc6w0000gp/T/fnm_multishells/12774_1710423566735/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.4 - /var/folders/sb/jdkc4cv91zvgvvzwhq9lyc6w0000gp/T/fnm_multishells/12774_1710423566735/bin/npm
  IDEs:
    VSCode: 1.87.2 - /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code
    Vim: 9.0 - /usr/bin/vim
    Xcode: 15.3/15E204a - /usr/bin/xcodebuild
  Browsers:
    Chrome: 122.0.6261.129
    Safari: 17.3.1
  npmPackages:
    vitest: ^1.4.0 => 1.4.0

Used Package Manager

npm

Validations

sheremet-va commented 6 months ago

This should be fixed by 29831757b628c7c44752420f568227dce17493fe in 0.5.2

I am marking this as "needs test" to catch the regression in the future, but for now, we are breaking things/moving fast.

chriswheeldon-peakon commented 6 months ago

@sheremet-va can confirm the extension now loads in that repository! Thanks 🤩

lestephane commented 5 months ago

Works for me too, is there a way to say "use vitest.explorer@^0.5.2" in devcontainer.json? I can't get that to work, and am forced to pin to a very specific version.