File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
Expand file tree Collapse file tree 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)
4141
4242### Find Option Object
4343
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+
4473#### Name
4574
4675Using 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')
5584Using a find option object, Vue Test Utils allows for selecting elements by ` $ref` on wrapper components.
5685
5786` ` ` js
58- const buttonWrapper = wrapper .find ({ ref: ' myButton ' })
87+ const buttonWrapper = wrapper .find ({ ref: ' dynamic-my-button-ref ' })
5988buttonWrapper .trigger (' click' )
6089` ` `
You can’t perform that action at this time.
0 commit comments