I'm using VueJs 3 with Vite and Cypress.
In my application I have an environment variable that defines my URL:
const url = import.meta.env.VITE_URL
My goal is to replace this VITE_URL
in Cypress. I try to create a cypress.env.json
file and write in it:
{ "VITE_URL": "https://...", }
But it doesn't work. I also tried CYPRESS_URL
or CYPRESS_VITE_URL
but I got the same result. Any ideas?
If you have declared the value in the
cypress.env.json
file, you can use `Cypress.env('varName'); to reference it in your codeOkay, I solved it. I created a
.env.testing
file and used it by specifying--mode test
in the npm command that started cypress.The properties of this env.testing are defined as follows: