Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check for undefined values on setPluginResolvedOn function #7960

Merged
merged 8 commits into from Jul 16, 2020
2 changes: 1 addition & 1 deletion packages/server/lib/config.js
Expand Up @@ -506,7 +506,7 @@ module.exports = {
// {value: obj.val, from: "plugin"}
setPluginResolvedOn (resolvedObj, obj) {
return _.each(obj, (val, key) => {
if (_.isObject(val) && !_.isArray(val)) {
if (_.isObject(val) && !_.isArray(val) && resolvedObj[key]) {
// recurse setting overrides
// inside of this nested objected
return this.setPluginResolvedOn(resolvedObj[key], val)
Expand Down
26 changes: 26 additions & 0 deletions packages/server/test/unit/config_spec.js
Expand Up @@ -1309,6 +1309,32 @@ describe('lib/config', () => {
},
})
})

// https://github.com/cypress-io/cypress/issues/7959
it('resolves a single object', () => {
jennifer-shehane marked this conversation as resolved.
Show resolved Hide resolved
const cfg = {
}
const obj = {
foo: {
bar: {
baz: 42,
},
},
}

config.setPluginResolvedOn(cfg, obj)

expect(cfg).to.deep.eq({
foo: {
from: 'plugin',
value: {
bar: {
baz: 42,
},
},
},
})
})
})

context('_.defaultsDeep', () => {
Expand Down