-
-
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
test.env
config not working in workspace project
#5016
Comments
I don't think it's meant to work in projects. Our architecture doesn't allow for envs there (like you already mentioned, it's passed down once when tinypool is initialized) |
I understand the current limitation, but I thought this feature would be nice-to-have for users if they simply expect Is it critical to allow overriding environment variable at the underlying level? For example, what I was thinking was to maybe we could do (I suppose |
If we do that, then we should use only a single way to assign env variables then. |
Describe the bug
The issue is originally reported in the discussion #5003 (I initially suspected mis-usage of
loadEnv
withprocess.cwd
, but it turned out to be irrelevant).The reproduction is here https://stackblitz.com/edit/github-2srz39?file=packages%2Flib1%2Fvite.config.ts
Given following configurations:
Running tests by
npm -C packages/lib1 test
succeeds butnpm test
fails.One simple workaround I thought of is to use
setupFiles
and do thisObject.assign(process.env, { ... your env ... })
manually.It looks like currently only the root
test.env
config is eventually passed tonew Tinypool
constructor (and shared between all thread/fork instances) but per-projecttest.env
config seems to be not used.vitest/packages/vitest/src/node/pool.ts
Lines 81 to 94 in 78b3840
Also btw, I noticed
env
config is not currently documented in https://vitest.dev/config/ but I also somehow knew this config (and actually recommended in remix vite doc https://remix.run/docs/en/main/future/vite#plugin-usage-with-other-vite-based-tools-eg-vitest-storybook). At least this is available fromdefineProject
typing, so I suppose this feature is meant to work for project level as well.Reproduction
https://stackblitz.com/edit/github-2srz39?file=packages%2Flib1%2Fvite.config.ts
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: