Open Eraph opened 1 month ago
You can assign a NODE_ENV
env in vitest.nodeEnv
or define the mode
property in your config.
Thanks for the response, @sheremet-va. Unfortunately as I mentioned in the original post, I already tried to set MODE in vitest.nodeEnv
, it looks like it is being ignored by the extension.
Which config are you referring to with regards to defining the mode
property?
Is there any reason why you won't just set mode
in the config?
export default defineConfig({
mode: 'vitest',
})
Yeah, we're passing in the mode like this:
export default defineConfig(({ mode }) => {
// Load env file based on `mode` in the current working directory.
const env = loadEnv(mode, process.cwd());
So test
could be a valid value, I would prefer not to overwrite it here.
Clear and concise description of the problem
I have joined a project where the Mode expected for running Vitest is
vitest
, for example, this NPM script frompackage.json
:In this case, Vitest will look for the environment variable file
.env.vitest
. I would prefer not to have to rename this file as its use is already well established.I can see that
process.env.MODE
is present and set totest
, but overriding it in settings has no effect; perhaps it is being set after reading settings?I can confirm that changing the filename to
.env.test
does allow it to be loaded.Please provide a means to specify the mode used by the Vitest extension.
Suggested solution
Support a setting like the following:
Apply this value to the environment variable
MODE
, or continue to use the valuetest
if not set.Alternative
No response
Additional context
No response
Validations