diff --git a/packages/test-utils/src/wrapper.js b/packages/test-utils/src/wrapper.js index f050c1da3..86a03f3d3 100644 --- a/packages/test-utils/src/wrapper.js +++ b/packages/test-utils/src/wrapper.js @@ -421,7 +421,8 @@ export default class Wrapper implements BaseWrapper { } Object.keys(data).forEach((key) => { - if (typeof data[key] === 'object' && data[key] !== null) { + if (typeof data[key] === 'object' && data[key] !== null && + !Array.isArray(data[key])) { // $FlowIgnore : Problem with possibly null this.vm const newObj = merge(this.vm[key], data[key]) // $FlowIgnore : Problem with possibly null this.vm diff --git a/test/specs/wrapper/setData.spec.js b/test/specs/wrapper/setData.spec.js index 47f9b07fe..3419d7fec 100644 --- a/test/specs/wrapper/setData.spec.js +++ b/test/specs/wrapper/setData.spec.js @@ -178,4 +178,17 @@ describeWithShallowAndMount('setData', (mountingMethod) => { expect(wrapper.vm.anObject.propA.prop1).to.equal('a') expect(wrapper.vm.anObject.propA.prop2).to.equal('b') }) + + it('sets array data properly', () => { + const TestComponent = { + data: () => ({ + items: [1, 2] + }) + } + const wrapper = mountingMethod(TestComponent) + wrapper.setData({ + items: [3] + }) + expect(wrapper.vm.items).to.deep.equal([3]) + }) })