vitest-dev / vscode

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

Vitest plugin fails to run tests in a monorepo with app-specific config #446

Closed shmichael closed 4 days ago

shmichael commented 1 month ago

Describe the bug

In our monorepo we have:

In the command line we run tests either globally (using turbo) or in specific apps (using pnpm -F appname test) - both work well.

However, the vitest vscode plugin is only able to run tests in the /packages subdir. The tests under /apps fail to run because vitest seems to expect the config file for the apps to be under the root:

WARNING: No configurations found in configuration directory: <repo root>/config

This is obviously not possible since different apps have different configs, which might overlap, and anyway we're interested in keeping app-specific configs under the relevant app.

Is there a fix that allows each app's test to correctly pull its relevant config?

Reproduction

Our repo is private

Output

This output replaces the root repo dir with <root> and the on disk path to root with <path>

[INFO 09:24:47] [v1.0.6] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 09:24:47] [API] Using user workspace config: <path>/vitest.workspace.ts
[INFO 09:24:48] [API] Running Vitest v1.6.0 (<root>/vitest.workspace.ts) with Node.js: <pnpm_path>
[INFO 09:24:48] [API] Vitest v1.6.0 (<root>/vitest.workspace.ts) process 34207 created
[INFO 09:30:21] Running 1 file(s): apps
[Worker] WARNING: NODE_ENV value of 'test' did not match any deployment config file names.
WARNING: See https://github.com/node-config/node-config/wiki/Strict-Mode
WARNING: No configurations found in configuration directory:<path>/config
WARNING: To disable this warning set SUPPRESS_NO_CONFIG_WARNING in the environment.

Version

1.0.6

Validations

sheremet-va commented 1 month ago

vitest seems to expect the config file for the apps to be under the root

This is not accurate.

Our repo is private

I cannot help you if you can't provide any sort of reproduction.

github-actions[bot] commented 1 month ago

Hello @shmichael. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

anantharam commented 3 weeks ago

I have added a minimal reproduction here : https://stackblitz.com/edit/vitest-dev-vitest-hkrvhg

You can see in this screenshot that the same test fails in vscode test and the test is passing when run from terminal : image