vitest icon indicating copy to clipboard operation
vitest copied to clipboard

Vite Environment Variables are not the correct type

Open tapoinde opened this issue 3 years ago • 1 comments

Describe the bug

Vite exposes several environment variables, 3 of which should be boolean import.meta.env.[DEV | PROD | SSR]. These variables are evaluating as strings while running tests.

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-maqvfr?file=test/basic.test.ts

System Info

All systems

Used Package Manager

npm

Validations

tapoinde avatar Feb 21 '23 19:02 tapoinde

Yes, it is mentioned in the documentation: https://vitest.dev/api/vi.html#vi-stubenv

Vitest transforms all import.meta.env into process.env, which is always a string.

sheremet-va avatar Feb 21 '23 19:02 sheremet-va