Allow environment-variables deep merging from "cypress.env.json" and system variables #29008
Labels
stage: proposal 💡
No work has been done of this issue
type: feature
New feature that does not currently exist
What would you like?
Allow deep merging of
cypress.env.json
, that is:for a
cypress.env.json
with:and a
cypress.config.js
with:The current result is: (
p2.a
will be lost)But would be better if it did a deep merge like the one from lodash:
Cypress._.merge(envFromCypressConfigJs, envFromCypressEnvJson)
Then for system environment variables to also support modifying a nested value without replacing the whole root object,
it can be done by passing a JSON string and using the same merging logic as lodash merge,
or it can also be done in a similar way that is done in dotnet AspNetCore config,
by using a delimiter like the double underscore
__
since in environment variables it is supported by all platforms.Example with double underscore:
CYPRESS_myConfig__subProperty=2
would change just theenv.myConfig.subProperty
Example with JSON:
CYPRESS_myConfig='{ "subProperty": 2 }'
would change just theenv.myConfig.subProperty
If this is a breaking change then it could have a feature flag to activate this new behavior like
useEnvironmentVariablesDeepMerge: true
incypress.config
.Why is this needed?
At the moment, when using
cypress.env.json
we are forced to duplicate all values within nested properties, unnecessarily duplicating things, and almost all config in our projects is within nested properties.Other
No response
The text was updated successfully, but these errors were encountered: