-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"cwd" is workspace root when running tests in sub directory projects #5277
Comments
Actually this is impossible for |
Hm, I thought the problem was with |
Before I found that this issue had already been created I was creating a reproducible example for it here: https://github.com/chriswheeldon-peakon/vitest-workspace-cwd. Just in case that's useful for anyone. My two cents is that I do think that this leaves vitest frustratingly at odds with other monorepo executors (e.g. npm -w and nx). For me the problem has arisen with packages that are using the |
I found this solution I find elegant since it works for every pool type, maybe it could be streamlined into
export default defineProject({
test: {
// Setup
setupFiles: ["./vitest.chdir.mts", /* anything */],
}
});
|
This is also problematic when you have plugins vite plugins which rely on the |
@paul-vd Can you share how plugins use |
In 1.5.0, the |
@sheremet-va is there a rationale for this? I think it should be also changed for tests. |
Technical limitations. Workers do not support |
Yeah but you can replace |
I'm also running into this issue due to to |
UPDATE: current workaround with
pool: "forks"
andsetupFiles
looks like this https://stackblitz.com/edit/vitest-dev-vitest-xedeud?file=packages%2Flib1%2Fvite.config.tsDescribe the bug
I've seen a similar behavior while I was investigating #5003, but I suppose this is not an intended behavior according to vitest-dev/vscode#254 (comment)
In the reproduction, I also checked cwd when loading config. Following logs are from running
console.log({ url: import.meta.url, cwd: process.cwd() })
in config files and test files:Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-4fbeln?file=packages%2Flib2%2Ftest%2Fsquare.test.ts
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: