What do you do when you need to modify the `baseUr...
# best-practices
a
What do you do when you need to modify the
baseUrl
in different environments? A THREAD:
Right now, I have a default set in
cypress.config.ts
and then I over-ride it in non-default environments as needed in my run script (in
package.json
). What I would like to do is specify it in a set of
/config/environmentName.json
files, OR dynamically construct it using a string value also stored in that same environmental JSON config.
Any way to do this, or is the run script the best place to explicitly state top-level config per environment?
f
We have a similar use case, and the
package.json
solution is the best approach we’ve found
g
https://on.cypress.io/configuration#Overriding-Options use the
setupNodeEvents
callback to construct the
baseUrl
and return it
Here is a typical example

https://youtu.be/butlgoP4SzI

a
@gray-kilobyte-89541 Thanks for this. After a bit of trial and error I was able to figure out how to do this correctly. I really like this new method.
7 Views