environment variables in baseUrl? #9321
Unanswered
marc-guenther
asked this question in
Questions and Help
Replies: 1 comment 1 reply
-
Look at the Settings tab in Second, do not set the base URL in the support file based on the environment variables, do it in the plugins file https://on.cypress.io/configuration-api (and you can even print the final variables to the terminal) |
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
-
Ok, this is rather strange and also somewhat silly, lemme try to explain...
We run Cypress on our CI system. The application it tests is build and deployed inside a Vagrant box, and the box forwards its port 80 to some port on the CI machine. As multiple test jobs can run at the same time, we cannot use a fixed port number for this, so instead we allocate a random port, and expose it as an environment variable:
VAGRANT_HTTP_PORT
To make this port available to all tests, I put this in my
cypress.json
:Unfortunately Cypress doesn't support env variables in the
baseUrl
, so I had to do it manually incypress/support/index.js
:That wasn't too hard, and it works perfectly fine on my Macbook, and all the CI Macs, all running Catalina. Except on one machine.
On the laptop of a collegue, when starting Cypress, she gets an error message, that says something like:
http://localhost:${VAGRANT_HTTP_PORT}/
cannot be reached. For some reason, the env variable is not replaced there, although it definitely has been set.Of course, this happens on the only machine, that, due to current lockdown, I do not really have access to. Which makes it rather hard to debug the problem. It is also running Catalina, it is the same Cypress version, running from the same repository. I am not aware of any significant difference in her machine vs. all the others.
Our current workaround is for her to hardcode the port in the
baseUrl
, and to remember to not check in that change. Not ideal, but it works.Any ideas are highly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions