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
I started a new project with Vite. Everything worked fine till i had to implement environment variables. I made it with documentation using import.meta and I noticed that all my tests associated with place where I used this syntax were broken.
I have stack:
React 17
TypeScript 4.5.2
jest 27
RTL
msw
Cypress
I tried a lot of solution from SO (like implement ts-jest, transformers in jest etc.) and even closed(why?) issues in Vite but it didn't work. I found a temporary workaround doing this:
To be able run application i had to define process.env in config. Without that i had blank screen. I also had to implement dotenv to see envs from files. Without that i saw only envs passed directly in package.json.
For now it works but I don't know what is the cost of this solution.
Suggested solution
Maybe building some preset for jest will be solution. Are there any plans for this?
Alternative
Currently there is no place in documention describing this problem or workaround. Perhaps, while there is no solution, it is worth describing the best workaround for this case.
Clear and concise description of the problem
I started a new project with Vite. Everything worked fine till i had to implement environment variables. I made it with documentation using
import.meta
and I noticed that all my tests associated with place where I used this syntax were broken.I have stack:
I tried a lot of solution from SO (like implement ts-jest, transformers in jest etc.) and even closed(why?) issues in Vite but it didn't work. I found a temporary workaround doing this:
To be able run application i had to define process.env in config. Without that i had blank screen. I also had to implement dotenv to see envs from files. Without that i saw only envs passed directly in package.json.
After that i had to read variable in old way to be able run tests. Without that jest cried about
import.meta
syntax.Finally I had to pass envs directly to Cypress configuration in plugins using process.env and dotenv.
For now it works but I don't know what is the cost of this solution.
Suggested solution
Maybe building some preset for jest will be solution. Are there any plans for this?
Alternative
Currently there is no place in documention describing this problem or workaround. Perhaps, while there is no solution, it is worth describing the best workaround for this case.
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: