Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
119 views
in Technique[技术] by (71.8m points)

javascript - How do I pass Cypress CLI arguments in the --env with a space?

I run Cypress from the command line as:

npx cypress open --env team=XXXX --config-file my_file.json

where my_file.json is my config file and contains:

env: {
    "team": ""
}

I know that when I pass a value via CLI with no space in it the Cypress runner will show that value in the configuration tab. How do I pass a value such as to team like:

--env team=XXXX XXXX

I have tried using "" and '' around the argument already and they have not worked. Thank you.

question from:https://stackoverflow.com/questions/65880503/how-do-i-pass-cypress-cli-arguments-in-the-env-with-a-space

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

From the documentation, it says "Pass several variables using commas and no spaces". So, off the bat, it sounds like what you're trying to do isn't possible. However, it may be worth a shot to try a different method. In particular, from this screenshot from the link I provided,

snippet

you can see that the last approach passes a JSON object. Perhaps, if for some reason Cypress parses this JSON object differently, you can try

cypress run --env team='{"key": "XXXX XXXX"}'

Alternatively, you could also have multiple Cypress configuration files, each with the relevant team value. However, if you have multiple team values, this simple approach doesn't scale particularly well.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...