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
Vitest VS extension appears not to be loading the default .env file when discovering tests. If I run yarn vitest the tests are executed as expected. If I specify manually the .env file then the VS Code extension seems to be behaving as exepcted. This issue only appears to be present in the VS extension.
Otherwise the discovery fails with "Config param DB_ID_HOST not defined" and the vitest output window shows:
[Worker] Collecting tests due to file changes: model/Org.test.t
[INFO 9:11:50 AM] [TEST] ❌ Config param DB_ID_HOST not defined.
The DB_ID_HOST obviously exists, Jest and Playwright have no issues with it and the code where the exception is raised works well.
The real issue here is: as the test dicovery has failed, I can't run any tests at the same level which renders the extension useless.
I would expect that the default .env file (ie in the root as per vitest.config.ts) is picked up by the extension and the vitest in general unless the user does not explicitly change this via the config file or otherwise. Alternatively the vitest quick guide needs to highlight that you must specify env for tests and extension to work.
Hello @moltco. 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.
Describe the bug
Vitest VS extension appears not to be loading the default .env file when discovering tests. If I run
yarn vitest
the tests are executed as expected. If I specify manually the .env file then the VS Code extension seems to be behaving as exepcted. This issue only appears to be present in the VS extension.The issue is similar to vitest-dev/vitest#2117 and https://stackoverflow.com/questions/61038365/node-js-not-recognizing-env-file If I manually add .env file to vitest.config.ts then the VS Code Extension works as expected.
Otherwise the discovery fails with "Config param DB_ID_HOST not defined" and the vitest output window shows:
The DB_ID_HOST obviously exists, Jest and Playwright have no issues with it and the code where the exception is raised works well.
The real issue here is: as the test dicovery has failed, I can't run any tests at the same level which renders the extension useless.
I would expect that the default .env file (ie in the root as per vitest.config.ts) is picked up by the extension and the vitest in general unless the user does not explicitly change this via the config file or otherwise. Alternatively the vitest quick guide needs to highlight that you must specify env for tests and extension to work.
Reproduction
Vitest.config.ts in case it helps reproduce
The failing line of code (ie the one that throws error) is in the db layer initialized in a pretty standard way
the getSafeConfig does very little - throws Error if process.env[paramName] === null || === undefined
Output
Version
vitest/1.6.0 win32-x64 node-v20.13.1 Extension v0.10.7
Validations
The text was updated successfully, but these errors were encountered: