From 26cd97ae1ead5b5a4b839880f4f32a3b38c04867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Fontcuberta?= Date: Sat, 11 Apr 2020 09:14:00 +0200 Subject: [PATCH] Add API reference for setProps --- src/api/README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/api/README.md b/src/api/README.md index 10fa1bb..3ffec75 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -619,6 +619,42 @@ test('emitted', () => { }) ``` +### `setProps` + +Updates component props. + +`setProps` returns `Vue.nextTick`, so you will have to call it with `await` to ensure the DOM has been updated before making an assertion. + +`Component.vue`: + +```vue + + + +``` + +`Component.spec.js` + +```js +test('updates prop', async () => { + const wrapper = mount(Component, { + props: { + message: 'hello' + } + }) + expect(wrapper.html()).toContain('hello') + + await wrapper.setProps({ message: 'goodbye' }) + expect(wrapper.html()).toContain('goodbye') +}) +``` + ### `setValue` Sets a value on DOM element, including: