How do I send baseUrl as a parameter with Cypress.io

You have to set the env variable CYPRESS_baseUrl

CYPRESS_baseUrl=[your baseUrl] npm run cypress:open should do it for you


What I did was simply:

export CYPRESS_BASE_URL=SOME_OTHER_URL
yarn cypress run

This will override the baseUrl configuration. See: https://docs.cypress.io/guides/guides/environment-variables.html#Overriding-Configuration


I think the correct way to do this is:

$ npm run cypress:open --config "baseUrl=myUrl"

Otherwise, the config parameter is passed to npm instead of cypress.

Good luck!


Brendan's answer is correct. I would like to add that

$ npm run cypress:open --config "baseUrl=myUrl"

may not be working since you try to propagate some configuration into a command inside your package.json. If instead you'd do for example:

$ ./node_modules/.bin/cypress run --config baseUrl=myUrl

it should work just fine.

This is good to know since it will let you use additional CLI options as well (which you do not know ahead of time).

PS: --env wouldn't work for baseUrl since baseUrl is a built-in configuration value and not a regular env variable.

Tags:

Cypress