Skip to content

Commit 644917a

Browse files
authored
docs: clarify findComponent vs getComponent (#2435)
1 parent a521fd6 commit 644917a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

docs/api/index.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,11 @@ find<T extends Node = Node>(selector: string | RefSelector): DOMWrapper<T>;
10281028
10291029
You can use the same syntax `querySelector` implements. `find` is basically an alias for `querySelector`. In addition you can search for element refs.
10301030
1031+
It is similar to `get`, but `find` returns an ErrorWrapper if an element is not found while [`get`](#get) will throw an error.
1032+
1033+
As a rule of thumb, always use `find` when you are asserting something doesn't exist. If you are asserting something does exist, use [`get`](#get).
1034+
1035+
10311036
`Component.vue`:
10321037
10331038
```vue
@@ -1174,7 +1179,7 @@ test('findComponent', () => {
11741179
```
11751180
11761181
:::warning
1177-
If `ref` in component points to HTML element, `findComponent` will return empty wrapper. This is intended behaviour
1182+
If `ref` in component points to HTML element, `findComponent` will return empty wrapper. This is intended behaviour.
11781183
:::
11791184
11801185
:::warning Usage with CSS selectors
@@ -1319,7 +1324,7 @@ getComponent<T extends ComponentPublicInstance>(selector: any): Omit<VueWrapper<
13191324
13201325
**Details:**
13211326
1322-
It is similar to `findComponent`, but `getComponent` throws instead of returning a ErrorWrapper.
1327+
It is similar to `findComponent`, but `getComponent` throws an error if a Vue Component instance is not found while [`findComponent`](#findComponent) will return an ErrorWrapper.
13231328
13241329
**Supported syntax:**
13251330

0 commit comments

Comments
 (0)