cypress-io / cypress-example-recipes

Various recipes for testing common scenarios with Cypress

Home Page:https://on.cypress.io/examples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can you clarify your example for "Environment variables"

djangofan opened this issue · comments

Can you clarify your example for "Environment variables"

The documentation does not answer this question: https://docs.cypress.io/guides/guides/environment-variables#Option-1-configuration-file

It appears you are suggesting that I hard-code the env-name in my code (

). I cannot do that. Can you clarify how I could pass the environment name to the Cypress tests, on the command line at execution time, to load a group of variables? Your example makes no attempt to answer that question.

You cannot hardcore the environment variable name? How does your test then know what to access? Can you give pseudocode for what you are trying to do or want to achieve

I was able to find the document that clarified it, which provides some sample code. It worked for me. Problem was that this document was not easy to find , since I was assuming that the previously mentioned link was the only documentation on this stuff.

So, the solution was found here:
https://docs.cypress.io/api/plugins/configuration-api#Switch-between-multiple-configuration-files

Would be nice to bake that into an example don't you think?