Cypress: Running "Cypress run" with multiple options from the Command Line does not work

Created on 12 Jul 2018  路  7Comments  路  Source: cypress-io/cypress

Current behavior:

When running the command below, it's not working:

./node_modules/.bin/cypress run --browser chrome --config baseUrl=http://localhost:45/

Desired behavior:

Cypress should start with the baseUrl configuration variable overriden and the browser being Chrome.

As a personal note, this may be because of inexperience or incorrect formating (I'm fairly new to Cypress, been using it for two weeks) as in the official Cypress doc it only gives one example using two different options (--headed --no-exit) and I'm using --browser and --config.

We need this to work as it's the command that will be executed in an automated task every night for E2E testing.

cli

Most helpful comment

I have found that in my case adding single quotes around the thing i am passing in to the -s flag fixed my problem. So it could be that @Bkucera had the right idea. The underlying library that cypress is using (commander) does allow for multiple flags so it is probably a parsing error in that library... it seems to choke on extra spaces or missing ' ' around the value

All 7 comments

Hi, can you try putting quotes around the url ?

I cannot as I have it using a VSTS variable.
For me it looks like this:

./node_modules/.bin/cypress run --browser chrome --config baseUrl=$(myUrlVariable)

I tried both with the url within quotes and the variable within quotes, and it's not working neither.
Hopefully one of the devs will have an answer :)

I'm having a similar issue.
npx cypress run --config baseUrl=http://localhost:3001 --browser chrome and
npx cypress run --config baseUrl="http://localhost:3001" --browser chrome and
npx cypress run -c baseUrl=http://localhost:3001 -b chrome and
npx cypress run -c baseUrl="http://localhost:3001" -b chrome
all yeild

npx: installed 1 in 1.496s
Path must be a string. Received undefined
C:\my\path\node_modules\cypress\bin\cypress

And then bash opens a new line.
My project is on 3.0.2 and I'm using bash.

EDIT: I found a round about solution for this particular situation:
set CYPRESS_BASE_URL=http://localhost:3001&& npx cypress run --browser chrome or export CYPRESS_BASE_URL=http://localhost:3001&& npx cypress run --browser chrome for cmd/powershell.

(note the lack of space between the url and &&, leaving a space registers the url as http://localhost:3001[SPACE] instead of http://localhost:3001, which causes cypress to stick random port numbers in.)

npx cypress run --config something=configured --browser chrome --headed works as expected, so I don't believe this is an issue of using cli with multiple flags. I found that the colon in the url was the problem.
npx cypress run --config baseUrl=http://localhost --browser chrome works as expected, but npx cypress run --config baseUrl=http://localhost:3001 --browser chrome does not.

I believe this is caused by the --browser option. For example, I can use --config and --env at the same time, but as soon as --browser comes into the mix, cypress aborts without any message,

I have noticed a similar behavior using --env and --spec in the same cypress run command

I have found that in my case adding single quotes around the thing i am passing in to the -s flag fixed my problem. So it could be that @Bkucera had the right idea. The underlying library that cypress is using (commander) does allow for multiple flags so it is probably a parsing error in that library... it seems to choke on extra spaces or missing ' ' around the value

There have been some improvements to the handling of these config options since this issue was opened. I suggest updating to the current version of Cypress and also using single quotes when passing values in the cli.

Was this page helpful?
0 / 5 - 0 ratings