Skip to content

Add API reference for setProps #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<template>
<div>{{ message }}</div>
</template>

<script>
export default {
props: ['message'],
}
</script>
```

`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:
Expand Down