You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that vitest completely ignores a root option under the test property in a Vite configuration file if said file also has a root option at its root.
No matter what I set options.test.root to, vitest will always try and find test files in options.root rather than options.test.root. In my project, this fails because options.root and options.test.root are sibling directories.
This can be considered a bit of an edge case. I'm a Vue plugin developer and want to have a basic demo website in ./docs (i.e. that's where my index.html is) and my plugin source code in ./src. I don't want to maintain two separate Vite projects (one for docs; one for the plugin source) because Vue's architecture makes it impossible to test locally in this setup using npm link.
Workaround: Move the Vite entry points (in my case, the index.html file) into the project root. I don't like this because in my particular case, it makes for a weird project structure.
Reproduction
I'm happy to provide a minimal reproduction, but I think that the existence of #1158 and the following code serve as sufficient explanation for the behavior that I'm seeing.
Should Vitest behave this way? I think this not desirable. I think it prevents developers from locating their tests outside their general source directory (I don't do this personally, but I've seen it).
Describe the bug
It seems that vitest completely ignores a
root
option under thetest
property in a Vite configuration file if said file also has aroot
option at its root.No matter what I set
options.test.root
to, vitest will always try and find test files inoptions.root
rather thanoptions.test.root
. In my project, this fails becauseoptions.root
andoptions.test.root
are sibling directories.This can be considered a bit of an edge case. I'm a Vue plugin developer and want to have a basic demo website in
./docs
(i.e. that's where my index.html is) and my plugin source code in./src
. I don't want to maintain two separate Vite projects (one for docs; one for the plugin source) because Vue's architecture makes it impossible to test locally in this setup usingnpm link
.This was possibly introduced in #1164:
vitest/packages/vitest/src/node/create.ts
Line 26 in 95da4d6
Workaround: Move the Vite entry points (in my case, the index.html file) into the project root. I don't like this because in my particular case, it makes for a weird project structure.
Reproduction
I'm happy to provide a minimal reproduction, but I think that the existence of #1158 and the following code serve as sufficient explanation for the behavior that I'm seeing.
Should Vitest behave this way? I think this not desirable. I think it prevents developers from locating their tests outside their general source directory (I don't do this personally, but I've seen it).
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: