diff --git a/docs/en/api/wrapper/setProps.md b/docs/en/api/wrapper/setProps.md index 67ff3f3b1..7a55124c4 100644 --- a/docs/en/api/wrapper/setProps.md +++ b/docs/en/api/wrapper/setProps.md @@ -1,13 +1,13 @@ # setProps(props) -Sets `Wrapper` `vm` props and forces update. - -**Note the Wrapper must contain a Vue instance.** - - **Arguments:** - `{Object} props` -- **Example:** +- **Usage:** + +Sets `Wrapper` `vm` props and forces update. + +**Note the Wrapper must contain a Vue instance.** ```js import { mount } from 'vue-test-utils' @@ -16,5 +16,33 @@ import Foo from './Foo.vue' const wrapper = mount(Foo) wrapper.setProps({ foo: 'bar' }) -expect(wrapper.props().foo).toBe('bar') +expect(wrapper.vm.foo).to.equal('bar') +``` + +You can also pass a `propsData` object, which will initialize the Vue instance with passed values. + +``` js +// Foo.vue +export default { + props: { + foo: { + type: String, + required: true + } + } +} +``` + +``` js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo, { + propsData: { + foo: 'bar' + } +}) + +expect(wrapper.vm.foo).to.equal('bar') ```