vitest-dev / vscode

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

Error during vitest startup since v0.6.0 #396

Closed programmer24601 closed 1 month ago

programmer24601 commented 1 month ago

Describe the bug

I'm getting a Vitest startup error on:

Vitest itself runs fine, however, the extension falls over on startup. The latest version of the vitest extension to fully work for me is 0.4.1.

Experimenting with right-click -> Install Another Version...

Reproduction

At the moment I'm struggling to provide a reproduction of this. I've tried running the extension against the basic, workspace, react official examples here, which works in all cases, but for my own current project (a two-package npm workspace) consistently gets this error. Is there a debug mode I can enable to get a stack trace to help with this?

If there's nothing to go on I can try and whittle down the project into something barebones I can share, but that will take some time.

Output

[INFO 20:04:51] [v0.10.7] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 20:04:51] [API] Running Vitest: v1.6.0 (vitest.workspace.d.ts), v1.6.0 (vitest.workspace.js), v1.6.0 (vitest.workspace.ts)
[INFO 20:04:51] [API] Starting Vitest process with Node.js: /home/me/.asdf/shims/node
[Worker] ReferenceError: _default is not defined
[Error 20:04:52] [Error Error] Vitest process exited with code 1
Error: Vitest process exited with code 1
    at ChildProcess.d (/home/me/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:21:170)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)

Version

0.10.7

Validations

sheremet-va commented 1 month ago

This is a problem with your config file somehow

programmer24601 commented 1 month ago

Interesting. I'll try and reduce the project down to something I can share. In the mean time this is the (simplified) repo structure:

.
├── package.json
├── package-lock.json
├── packages
│   ├── backend
│   │   ├── bin
│   │   │   └── index.ts
│   │   ├── functions
│   │   │   ├── function-1
│   │   │   │   ├── handler.test.ts
│   │   │   │   └── handler.ts
│   │   │   ├── function-2
│   │   │   │   ├── handler.test.ts
│   │   │   │   └── handler.ts
│   │   │   └── function-3
│   │   │       ├── handler.test.ts
│   │   │       └── handler.ts
│   │   ├── lib
│   │   │   ├── stack.test.ts
│   │   │   ├── stack.ts
│   │   ├── package.json
│   │   ├── tsconfig.json
│   │   └── vitest.config.ts
│   └── frontend
│       ├── index.html
│       ├── package.json
│       ├── src
│       │   ├── App.test.tsx
│       │   ├── App.tsx
│       │   ├── index.tsx
│       │   ├── setupTests.ts
│       │   └── vite-env.d.ts
│       ├── tsconfig.json
│       └── vite.config.ts
├── tsconfig.json
├── vitest.config.ts
└── vitest.workspace.ts

Vitest 1.6.0 is installed as a devDependency in each of the three package.json.

sheremet-va commented 1 month ago

It shouldn't load vitest.workspace.d.ts file - why do you have it? And where? I don't see it in your example. You can add it to vitest.configSearchPatternExclude in the vscode settings

programmer24601 commented 1 month ago

You've solved it! tsc had transpiled vitest.workspace.ts into my outDir dist.