You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`shallowMount` is an alias to mounting a component with `shallow:true`.
570
+
:::
571
+
572
+
466
573
## Wrapper methods
467
574
468
575
When you use `mount`, a `VueWrapper` is returned with a number of useful methods for testing. A `VueWrapper` is a thin wrapper around your component instance. Methods like `find` return a `DOMWrapper`, which is a thin wrapper around the DOM nodes in your component and it's children. Both implement a similar same API.
@@ -859,6 +966,21 @@ test('html', () => {
859
966
})
860
967
```
861
968
969
+
### `isVisible`
970
+
971
+
Verify whether or not a found element is visible or not.
Returns props applied on a Vue Component. This should be used mostly to assert props applied to a stubbed component.
@@ -912,6 +1034,37 @@ test('props', () => {
912
1034
})
913
1035
```
914
1036
1037
+
### `setData`
1038
+
1039
+
Updates component data.
1040
+
1041
+
::: tip
1042
+
You should use `await` when you call `setData` to ensure that Vue updates the DOM before you make an assertion.
1043
+
:::
1044
+
1045
+
`Component.vue`:
1046
+
1047
+
```js
1048
+
test('updates component data', async () => {
1049
+
constComponent= {
1050
+
template:'<div>Count: {{ count }}</div>',
1051
+
data: () => ({ count:0 })
1052
+
}
1053
+
1054
+
constwrapper=mount(Component)
1055
+
expect(wrapper.html()).toContain('Count: 0')
1056
+
1057
+
awaitwrapper.setData({ count:1 })
1058
+
1059
+
expect(wrapper.html()).toContain('Count: 1')
1060
+
})
1061
+
```
1062
+
1063
+
Notice that `setData` does not allow setting new properties that are not
1064
+
defined in the component.
1065
+
1066
+
Also, notice that `setData` does not modify composition API `setup()` data.
1067
+
915
1068
### `setProps`
916
1069
917
1070
Updates component props.
@@ -1093,4 +1246,4 @@ test('unmount', () => {
1093
1246
1094
1247
### `vm`
1095
1248
1096
-
This is the ```Vue``` instance. You can access all of the [instance methods and properties of a vm](https://v3.vuejs.org/api/instance-properties.html) with ```wrapper.vm```. This only exists on ```VueWrapper```.
1249
+
This is the ```Vue``` instance. You can access all of the [instance methods and properties of a vm](https://v3.vuejs.org/api/instance-properties.html) with ```wrapper.vm```. This only exists on ```VueWrapper```.
0 commit comments