Skip to content

Commit 7e3f227

Browse files
committed
Documenting get method on wrapper #1298
1 parent ea39a3f commit 7e3f227

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Vue Test Utils is the official unit testing utility library for Vue.js.
4444
- [destroy](api/wrapper/destroy.md)
4545
- [find](api/wrapper/find.md)
4646
- [findAll](api/wrapper/findAll.md)
47+
- [get](api/wrapper/get.md)
4748
- [html](api/wrapper/html.md)
4849
- [is](api/wrapper/is.md)
4950
- [isEmpty](api/wrapper/isEmpty.md)

docs/api/wrapper/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ A `Wrapper` is an object that contains a mounted component or vnode and methods
3636
!!!include(docs/api/wrapper/find.md)!!!
3737
!!!include(docs/api/wrapper/findAll.md)!!!
3838
!!!include(docs/api/wrapper/html.md)!!!
39+
!!!include(docs/api/wrapper/get.md)!!!
3940
!!!include(docs/api/wrapper/is.md)!!!
4041
!!!include(docs/api/wrapper/isEmpty.md)!!!
4142
!!!include(docs/api/wrapper/isVisible.md)!!!

docs/api/wrapper/get.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## get
2+
3+
Works just like [find](../find.md) but will throw an error if selector not
4+
matching anything. You should use `find` when searching for an element that
5+
may not exist. You should use this method when getting an element that should
6+
exist and it will provide a nice error message if that is not the case.
7+
8+
```js
9+
import { mount } from '@vue/test-utils'
10+
11+
const wrapper = mount(Foo)
12+
13+
expect(() => wrapper.get('.does-not-exist'))
14+
.to.throw()
15+
.with.property(
16+
'message',
17+
'Unable to find .does-not-exist within: <div>the actual DOM here...</div>'
18+
)
19+
```

0 commit comments

Comments
 (0)