spectacles-ts
spectacles-ts copied to clipboard
Q: Working with arrays in nested objects
Taking the code from the modify example. Is it possible to just add elements to that array? Or how would you cover this example ?
const modified = pipe(
{ a: [{ b: 123 }] },
modify('a.[number]', [{ test: 'abc'} , {a: 456]])
)
// { a: [{ b: 123 }, {test: 'abc'} , {a: 456}] }
to give a broader look maybe you have something like the following
Cypress.Commands.add('mount', (component, options = {}) => {
// Setup options object
options.global = options.global || {}
options.global.stubs = options.global.stubs || {}
options.global.stubs['transition'] = false
options.global.components = options.global.components || {}
options.global.plugins = options.global.plugins || []
/* Add any global plugins */
// options.global.plugins.push(MyPlugin);
/* Add any global components */
// options.global.components['Button'] = Button;
return mount(component, options)
})
and you just want to use modify on options without the boilerplate