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?
cypress run --spec <spec> Run tests specifying a single test file to run instead of all tests. The spec path should be an absolute path or can relative to the current working directory.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With