Skip to content

Commit c3cbff3

Browse files
authored
docs: update vue api doc to match implementation for vue 3
chore: update vue api doc to match implementation
2 parents d61fd25 + b9d6941 commit c3cbff3

File tree

1 file changed

+13
-39
lines changed

1 file changed

+13
-39
lines changed

docs/vue-testing-library/api.mdx

+13-39
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,44 @@ title: API
77

88
It also exposes these methods:
99

10-
- [`render(Component, options, callback)`](#rendercomponent-options-callback)
10+
- [`render(Component, options)`](#rendercomponent-options)
1111
- [Parameters](#parameters)
1212
- [Component](#component)
1313
- [Options](#options)
14-
- [Callback Function](#callback-function)
1514
- [`render` result](#render-result)
1615
- [`...queries`](#queries)
1716
- [`container`](#container)
1817
- [`baseElement`](#baseelement)
19-
- [`debug(element)`](#debugelement)
20-
- [`unmount()`](#unmount)
21-
- [`isUnmounted()`](#isunmounted)
22-
- [`html()`](#html)
23-
- [`emitted()`](#emitted)
24-
- [`updateProps(props)`](#updatepropsprops)
18+
- [`debug`](#debugelement)
19+
- [`unmount`](#unmount)
20+
- [`html`](#html)
21+
- [`emitted`](#emitted)
22+
- [`rerender`](#rerenderprops)
2523
- [`fireEvent`](#fireevent)
2624
- [`touch(elem)`](#touchelem)
2725
- [`update(elem, value)`](#updateelem-value)
2826
- [`cleanup`](#cleanup)
2927

3028
---
3129

32-
## `render(Component, options, callback)`
30+
## `render(Component, options)`
3331

3432
The `render` function is the only way of rendering components in Vue Testing
3533
Library.
3634

37-
It takes up to 3 parameters and returns an object with some helper methods.
35+
It takes up to 2 parameters and returns an object with some helper methods.
3836

3937
```js
4038
function render(Component, options, callbackFunction) {
4139
return {
4240
...DOMTestingLibraryQueries,
4341
container,
4442
baseElement,
45-
debug,
43+
debug(element),
4644
unmount,
47-
isUnmounted,
4845
html,
4946
emitted,
50-
updateProps,
47+
rerender(props),
5148
}
5249
}
5350
```
@@ -106,20 +103,6 @@ If the `container` is specified, then this defaults to that, otherwise this
106103
defaults to `document.body`. `baseElement` is used as the base element for the
107104
queries as well as what is printed when you use `debug()`.
108105

109-
#### Callback Function
110-
111-
```js
112-
function callbackFunction(vueInstance, vuexStore, router) {}
113-
```
114-
115-
A callback function that receives the Vue instance as a parameter. Its return
116-
value is merged with [options](#options), allowing 3rd party plugins to be
117-
installed prior to mount. To see how this works, see the example using
118-
[`vue-i18n`](https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__/translations-vue-i18n.js).
119-
120-
The function will also receive the Store or the Router object if the associated
121-
option was passed in during render.
122-
123106
### `render` result
124107

125108
The `render` method returns an object that has a few properties:
@@ -168,9 +151,6 @@ renders its HTML directly in the body.
168151

169152
This method is a shortcut for `console.log(prettyDOM(element))`.
170153

171-
`element` can either be a DOM element or an array containing DOM elements. It
172-
defaults to `baseElement`
173-
174154
```jsx
175155
import {render} from '@testing-library/vue'
176156

@@ -183,8 +163,6 @@ debug()
183163
// <div>
184164
// <h1>Hello World</h1>
185165
// </div>
186-
187-
// you can also pass an element: debug(getByTestId('messages'))
188166
```
189167

190168
This is a simple wrapper around `prettyDOM` which is also exposed and comes from
@@ -195,10 +173,6 @@ This is a simple wrapper around `prettyDOM` which is also exposed and comes from
195173
An alias for `@vue/test-utils`
196174
[destroy](https://vue-test-utils.vuejs.org/api/wrapper/#destroy).
197175

198-
#### `isUnmounted()`
199-
200-
Returns whether if a Vue component has been destroyed.
201-
202176
#### `html()`
203177

204178
An alias for `@vue/test-utils`
@@ -209,12 +183,12 @@ An alias for `@vue/test-utils`
209183
An alias for `@vue/test-utils`
210184
[emitted](https://vue-test-utils.vuejs.org/api/wrapper/#emitted).
211185

212-
#### `updateProps(props)`
186+
#### `rerender(props)`
213187

214188
An alias for `@vue/test-utils`
215-
[setProps](https://vue-test-utils.vuejs.org/api/wrapper/#setprops).
189+
[setProps](https://test-utils.vuejs.org/api/#setprops).
216190

217-
It returns a Promise through `wait()`, so you can `await updateProps(...)`.
191+
It returns a Promise through so you can `await rerender(...)`.
218192

219193
---
220194

0 commit comments

Comments
 (0)