Skip to content
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
7 changes: 2 additions & 5 deletions src/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ test('findAllComponents', () => {

### `get`

Similar to `find`, `get` looks for an element and returns a `DOMWrapper` if one is found. Otherwise it throws an error.
Similar to `find`, `get` looks for an element and returns a `DOMWrapper` if one is found. Otherwise it throws an error. As a rule of thumb, always use get except when you are asserting something doesn't exist. In that case use [`find`](#find).

`Component.vue`:

Expand All @@ -773,13 +773,10 @@ test('get', () => {
const wrapper = mount(Component)

wrapper.get('span') //=> found; returns DOMWrapper
wrapper.get('[data-test="span"]') //=> found; returns DOMWrapper

expect(() => wrapper.getComponent('p')).toThrowError()
wrapper.get('[data-test="span"]') //=> found; returns DOMWrapper, fails if no matching element is found
})
```


### `getComponent`

Similar to `findComponent`, `getComponent` looks for a Vue Component instance and returns a `VueWrapper` if one is found. Otherwise it throws an error.
Expand Down