Unable to use deeply nested config or env in plugins
See original GitHub issueCurrent behavior:
When returning deeply nested config in the plugin, an error is shown on startup. “Unable to set property {propertyname} of undefined.”
Desired behavior:
When returning deeply nested config in the plugin, the config should be merged into the main config, and no error is shown.
Steps to reproduce:
Simply place the following in your plugins/index.js
file.
module.exports = () => ({
foo: {
bar: 'baz',
},
});
Versions
Cypress version 2.1.0
Other info
I did a little bit of digging and it tries to merge this extra config into “resolved” config but as cfg.resolved.foo
doesn’t exist, it fails.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:11
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Using environment variables with Webpack
A guide for setting up and using environment variables with Webpack and handling ... Add it to the plugins in your webpack config...
Read more >Environment Variables
Pain to write the --env options everywhere you use Cypress. No support for nested fields. Option #5: Test Configuration. You can set environment...
Read more >You are reading environment variables the wrong way in ...
In a scenario where you build the application without having set the API_KEY environment variable the application will use undefined instead.
Read more >Environment Variables - Cypress
It is a pain to write the --env options everywhere you use Cypress. It has no support for nested fields. Option #5: Plugins....
Read more >dotenv file is not loading environment variables
Use only absolute path if you are using some other tool(installed globally) to call your config file somewhere .
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
Yeah, I was trying to use separate config files per environment following the Config API docs here: https://docs.cypress.io/api/plugins/configuration-api.html#Promises
Nested values in my Cypress.json work fine, but when following the above pattern I’m also getting the same error:
Eg. We’re trying to use values like this:
In our app we needed to lean on
node-config
to deal with per-environment configurations. We ended up doing something like:in
plugins/index.js
and something like:in the tests. This approach seems to work fine for deeply nested structures.