File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -619,6 +619,42 @@ test('emitted', () => {
619
619
})
620
620
```
621
621
622
+ ### ` setProps `
623
+
624
+ Updates component props.
625
+
626
+ ` setProps ` returns ` Vue.nextTick ` , so you will have to call it with ` await ` to ensure the DOM has been updated before making an assertion.
627
+
628
+ ` Component.vue ` :
629
+
630
+ ``` vue
631
+ <template>
632
+ <div>{{ message }}</div>
633
+ </template>
634
+
635
+ <script>
636
+ export default {
637
+ props: ['message'],
638
+ }
639
+ </script>
640
+ ```
641
+
642
+ ` Component.spec.js `
643
+
644
+ ``` js
645
+ test (' updates prop' , async () => {
646
+ const wrapper = mount (Component, {
647
+ props: {
648
+ message: ' hello'
649
+ }
650
+ })
651
+ expect (wrapper .html ()).toContain (' hello' )
652
+
653
+ await wrapper .setProps ({ message: ' goodbye' })
654
+ expect (wrapper .html ()).toContain (' goodbye' )
655
+ })
656
+ ```
657
+
622
658
### ` setValue `
623
659
624
660
Sets a value on DOM element, including:
You can’t perform that action at this time.
0 commit comments