File tree 1 file changed +30
-1
lines changed
1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,35 @@ expect(wrapper.is(Foo)).toBe(true)
41
41
42
42
### Find Option Object
43
43
44
+ Suppose you have the following component
45
+ ``` js
46
+ // MyButtonComponent.vue
47
+
48
+ < template>
49
+ < button class = " btn" name= " my-button" : ref= " myButtonRef" > Click My Button< / button>
50
+ < / template>
51
+ < script lang= " ts" >
52
+ export default defineComponent ({
53
+ name: ' MyButtonComponent' ,
54
+ computed: {
55
+ myButtonRef () {
56
+ return ' dynamic-my-button-ref' ;
57
+ }
58
+ }
59
+ < / script>
60
+
61
+ or
62
+
63
+ const MyButtonComponent = {
64
+ template: ' <button class="btn" name="my-button" :ref="myButtonRef">Click My Button</button>' ,
65
+ computed: {
66
+ myButtonRef () {
67
+ return ' dynamic-my-button-ref' ;
68
+ }
69
+ }
70
+ };
71
+ ` ` `
72
+
44
73
#### Name
45
74
46
75
Using a find option object, Vue Test Utils allows for selecting elements by a ` name` of component on wrapper components.
@@ -55,6 +84,6 @@ buttonWrapper.trigger('click')
55
84
Using a find option object, Vue Test Utils allows for selecting elements by ` $ref` on wrapper components.
56
85
57
86
` ` ` js
58
- const buttonWrapper = wrapper .find ({ ref: ' myButton ' })
87
+ const buttonWrapper = wrapper .find ({ ref: ' dynamic-my-button-ref ' })
59
88
buttonWrapper .trigger (' click' )
60
89
` ` `
You can’t perform that action at this time.
0 commit comments