vitest-dev / vscode

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

When using babel plugins in vite react config, vitest extension throws error when one of the test files changes #379

Closed jtiala closed 1 month ago

jtiala commented 2 months ago

Describe the bug

When using babel plugins (at least the formatjs plugin) in Vite config, vitest extension throws error Error: Cannot find package 'babel-plugin-formatjs' imported from /babel-virtual-resolve-base.js when one of the test files changes.

Reproduction

https://github.com/jtiala/vitest-vscode-babel-plugin-bug-repro

  1. Run tests in Vitest VS Code extension. They should run fine. Re-running and refressing works.
  2. Make any change in sum.test.ts and save.
  3. The extension throws error Error: Cannot find package 'babel-plugin-formatjs' imported from /babel-virtual-resolve-base.js

screenshot

  1. This breaks some features of the extension. Tests cannot be run from the gutter, for example.
  2. Refreshing tests or running all tests gets rid of the error and allows the extension to function correctly, up until the next save in any test file.
  3. When running tests from the command line, this doesn't happen.

Output

[INFO 9.02.48] Running 1 file(s) with name pattern: ^\s?adds 1 \+ 2 to equal 3$
[Worker] Collecting tests due to file changes: src/sum.test.ts

Version

v0.10.2

Validations