cypress-io / cypress-documentation

Cypress Documentation including Guides, API, Plugins, Examples, & FAQ.
https://docs.cypress.io
MIT License
940 stars 1.04k forks source link

Environment Variables Guide states (wrongly?) that CLI --env doesn't support nested fields. #5718

Open LazaroOnline opened 7 months ago

LazaroOnline commented 7 months ago

Subject

Guides

Description

In this guide: https://docs.cypress.io/guides/guides/environment-variables#Option-4---env

In the "Downsides" section for CLI it states: "No support for nested fields", however I DO can pass nested fields from the CLI --env parameter by using JSON string values:

The cypress docs for --env param shows the use of JSON parameters.

And tested by me in Cypress v13.6.3, example from package.json scripts:

"cy:open": "cypress open --env \"{\\\"conf1\\\":\\\"val 1,2\\\", \\\"nested\\\":{\\\"subProp\\\":true}}\"", 

or as a simple command: cypress open --env '{"conf1":"val 1,2", "nested": { "subProp": true } }'

Also by using JSON I can pass special characters within string values like single/double quotes and spaces.

Should the guide be updated to document the JSON values and state that nested fields are supported?

jennifer-shehane commented 7 months ago

@LazaroOnline We'd be open to a PR to fix this.