cypress-documentation icon indicating copy to clipboard operation
cypress-documentation copied to clipboard

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

Open LazaroOnline opened this issue 1 year ago • 1 comments

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?

LazaroOnline avatar Feb 25 '24 19:02 LazaroOnline

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

jennifer-shehane avatar Feb 26 '24 15:02 jennifer-shehane