22
33Returns ` Wrapper ` of first DOM node or Vue component matching selector.
44
5- Use any valid [ selector] ( ../selectors.md ) .
5+ Use any valid DOM selector (uses ` querySelector ` syntax ).
66
77- ** Arguments:**
88
9- - ` {string|Component } selector `
9+ - ` {string} selector `
1010
1111- ** Returns:** ` {Wrapper} `
1212
@@ -20,34 +20,19 @@ import Bar from './Bar.vue'
2020const wrapper = mount (Foo)
2121
2222const div = wrapper .find (' div' )
23- expect (div .is ( ' div ' )).toBe (true )
23+ expect (div .exists ( )).toBe (true )
2424
25- const bar = wrapper .find (Bar)
26- expect (bar .is (Bar)).toBe (true )
27-
28- const barByName = wrapper .find ({ name: ' bar' })
29- expect (barByName .is (Bar)).toBe (true )
30-
31- const fooRef = wrapper .find ({ ref: ' foo' })
32- expect (fooRef .is (Foo)).toBe (true )
25+ const byId = wrapper .find (' #bar' )
26+ expect (byId .element .id ).toBe (' bar' )
3327```
3428
3529- ** Note:**
3630
37- - When chaining ` find ` calls together, only DOM selectors can be used
31+ - You may chain ` find ` calls together:
3832
3933``` js
4034let button
4135
42- // Will throw an error
43- button = wrapper .find ({ ref: ' testButton' })
44- expect (button .find (Icon).exists ()).toBe (true )
45-
46- // Will throw an error
47- button = wrapper .find ({ ref: ' testButton' })
48- expect (button .find ({ name: ' icon' }).exists ()).toBe (true )
49-
50- // Will work as expected
5136button = wrapper .find ({ ref: ' testButton' })
5237expect (button .find (' .icon' ).exists ()).toBe (true )
5338```
0 commit comments