Passing parameters to cypress using cli
See original GitHub issueHi,
Is There a way we can pass command line arguments to a cypress script in order to make it truly scalable .
To explain in detail , We have a script a.j
s That selects some values from list boxes(As of now these values are hardcode) . If there is a way we can parametrize these values , then the same script can be used to select multiple values
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Command Line - Cypress Documentation
When calling a command using npm run , you need to pass the command's arguments using the -- string. For example, if you...
Read more >How do I pass Cypress CLI arguments in the --env with a space?
From the documentation, it says "Pass several variables using commas and no spaces". So, off the bat, it sounds like what you're trying...
Read more >How to pass command line options to Cypress? - Knapsack Pro
IMPORTANT: Only argument listed in Cypress CLI options list work. If you want to pass options related to Node you should use NODE_OPTIONS...
Read more >Command Line - cypress - w3resource
json file and then call it from an npm run script. Whenever you call a command using npm run, you will have to...
Read more >Part 21 - Run Cypress Tests from Command Line - YouTube
Part 21 - Run Cypress Tests from Command Line | Pass Environment Variables from Command Line.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
krishvv,
I’m pretty sure you can already achieve what you want here through the use of environment variables (which you can specify in the command line). While your use case is slightly different, see https://on.cypress.io/configuration-api#Usage for a general example.
We, for example, load up a bunch of different configurations depending on our environment. You can extend this beyond just route/visit. The note at the end of the page is especially important to remember…it’s just js, so you can make things as programmatically variable as you’d like.
So, loosely, in your case, you might have a
cypress/config/
folder which contains (in.js
orjson
, depending on your setup) alegalname.js
,releaselevel.js
, (etc). Which config context is invoked here is called (from the example above) from the cli when you open Cypress.Then within that file you define variable that are different for each setup. So your code becomes:
Of course that’s just a general abstraction after a brief glance at what you need. But it should give an idea of how to accomplish what you want. It’s probably not the only solution, but it’s the one that seems to be the easiest ‘fit’ for your situation. Hope it helps.
Issues in our GitHub repo are reserved for potential bugs or feature requests. This issue will be closed since it appears to be neither a bug nor a feature request.
We recommend questions relating to how to use Cypress be asked in our community chat. Also try searching our existing GitHub issues, reading through our documentation, or searching Stack Overflow for relevant answers.
Alternatively, signing up for any of you paid plans gives you access to our team for support via email. If you would like something higher touch, we also offer screen sharing and workshops with our premium support options.