Zod validation for .env throws errors in testing sidebar #407
Unanswered
jacknevitt
asked this question in
Q&A
Replies: 1 comment 1 reply
-
You can set env in the Vitest config file, or via |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In my typescript project, I validate the env variables with Zod like this:
This is validated at build time and the variables can be used reliably across the app. The
env
is then imported like so:And then the test file like so:
However, when exploring the vitest tests in the vscode testing panel, there are zod errors shown and the tests fail when run from the sidebar. The tests pass with
npm run test
.Is there a way to set .env variables for the extension? I have a
__mocks__/env.server.ts
file, but mocking the file in the test doesn't help.Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions