Search code examples
cypress

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


I am researching switching from Protractor to Cypress.io. I have some tests up and running, however, I want to be able to send the baseUrl as a parameter as I can with Protractor.

I have tried:

$ npm run cypress:open --config "baseUrl=myUrl" --still uses the baseUrl from my config file.

$ npm run cypress:open --env "baseUrl=myUrl" --still uses the baseUrl from my config file.

and a host of other things, none of which work quite right.

I want to be able to pass a parameter to my command which gives me the flexibility to choose which environment I am running my tests in. I can do this with Protractor, with a command like this:

$ ng e2e --suite testSuite --baseUrl myUrl

What is the equivalent for Cypress.io?


Solution

  • You have to set the env variable CYPRESS_baseUrl

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