@@ -7,47 +7,44 @@ title: API
7
7
8
8
It also exposes these methods:
9
9
10
- - [ ` render(Component, options, callback ) ` ] ( #rendercomponent-options-callback )
10
+ - [ ` render(Component, options) ` ] ( #rendercomponent-options )
11
11
- [ Parameters] ( #parameters )
12
12
- [ Component] ( #component )
13
13
- [ Options] ( #options )
14
- - [ Callback Function] ( #callback-function )
15
14
- [ ` render ` result] ( #render-result )
16
15
- [ ` ...queries ` ] ( #queries )
17
16
- [ ` container ` ] ( #container )
18
17
- [ ` 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 )
25
23
- [ ` fireEvent ` ] ( #fireevent )
26
24
- [ ` touch(elem) ` ] ( #touchelem )
27
25
- [ ` update(elem, value) ` ] ( #updateelem-value )
28
26
- [ ` cleanup ` ] ( #cleanup )
29
27
30
28
---
31
29
32
- ## ` render(Component, options, callback ) `
30
+ ## ` render(Component, options) `
33
31
34
32
The ` render ` function is the only way of rendering components in Vue Testing
35
33
Library.
36
34
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.
38
36
39
37
``` js
40
38
function render (Component , options , callbackFunction ) {
41
39
return {
42
40
... DOMTestingLibraryQueries,
43
41
container,
44
42
baseElement,
45
- debug,
43
+ debug (element) ,
46
44
unmount,
47
- isUnmounted,
48
45
html,
49
46
emitted,
50
- updateProps ,
47
+ rerender (props) ,
51
48
}
52
49
}
53
50
```
@@ -106,20 +103,6 @@ If the `container` is specified, then this defaults to that, otherwise this
106
103
defaults to ` document.body ` . ` baseElement ` is used as the base element for the
107
104
queries as well as what is printed when you use ` debug() ` .
108
105
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
-
123
106
### ` render ` result
124
107
125
108
The ` render ` method returns an object that has a few properties:
@@ -168,9 +151,6 @@ renders its HTML directly in the body.
168
151
169
152
This method is a shortcut for ` console.log(prettyDOM(element)) ` .
170
153
171
- ` element ` can either be a DOM element or an array containing DOM elements. It
172
- defaults to ` baseElement `
173
-
174
154
``` jsx
175
155
import {render } from ' @testing-library/vue'
176
156
@@ -183,8 +163,6 @@ debug()
183
163
// <div>
184
164
// <h1>Hello World</h1>
185
165
// </div>
186
-
187
- // you can also pass an element: debug(getByTestId('messages'))
188
166
```
189
167
190
168
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
195
173
An alias for ` @vue/test-utils `
196
174
[ destroy] ( https://vue-test-utils.vuejs.org/api/wrapper/#destroy ) .
197
175
198
- #### ` isUnmounted() `
199
-
200
- Returns whether if a Vue component has been destroyed.
201
-
202
176
#### ` html() `
203
177
204
178
An alias for ` @vue/test-utils `
@@ -209,12 +183,12 @@ An alias for `@vue/test-utils`
209
183
An alias for ` @vue/test-utils `
210
184
[ emitted] ( https://vue-test-utils.vuejs.org/api/wrapper/#emitted ) .
211
185
212
- #### ` updateProps (props)`
186
+ #### ` rerender (props)`
213
187
214
188
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 ) .
216
190
217
- It returns a Promise through ` wait() ` , so you can ` await updateProps (...) ` .
191
+ It returns a Promise through so you can ` await rerender (...) ` .
218
192
219
193
---
220
194
0 commit comments