diff --git a/packages/create-instance/create-instance.js b/packages/create-instance/create-instance.js index 6236fe243..80fa5594d 100644 --- a/packages/create-instance/create-instance.js +++ b/packages/create-instance/create-instance.js @@ -57,7 +57,7 @@ export default function createInstance ( const Constructor = vue.extend(component) - const instanceOptions = { ...options } + const instanceOptions = { ...options, propsData : { ...options.propsData } } deleteoptions(instanceOptions) // $FlowIgnore const stubComponents = createComponentStubs(component.components, options.stubs) diff --git a/test/specs/mounting-options/propsData.spec.js b/test/specs/mounting-options/propsData.spec.js new file mode 100644 index 000000000..e88c5dc44 --- /dev/null +++ b/test/specs/mounting-options/propsData.spec.js @@ -0,0 +1,34 @@ +import { shallowMount } from '~vue/test-utils' +import ComponentWithProps from '~resources/components/component-with-props.vue' +import { describeIf } from '~resources/utils' + +const baseData = { + prop1: ['', ''] +}; + +describeIf(process.env.TEST_ENV !== 'node', + 'propsData', () => { + let wrapper + + beforeEach(() => { + wrapper = shallowMount(ComponentWithProps, { + propsData : baseData, + }) + }) + + afterEach(() => { + wrapper = null + }) + + describe('should not modify propsData between tests', () => { + it('should have the correct props after modifying', () => { + expect(wrapper.vm.prop1).to.have.length(2) + wrapper.setProps({ prop1: [] }); + expect(wrapper.vm.prop1).to.have.length(0) + }) + + it('should have the default props despite being modified in the previous test', () => { + expect(wrapper.vm.prop1).to.have.length(2) + }) + }) + })