File tree Expand file tree Collapse file tree 1 file changed +34
-6
lines changed Expand file tree Collapse file tree 1 file changed +34
-6
lines changed Original file line number Diff line number Diff line change 11# setProps(props)
22
3- Sets ` Wrapper ` ` vm ` props and forces update.
4-
5- ** Note the Wrapper must contain a Vue instance.**
6-
73- ** Arguments:**
84 - ` {Object} props `
95
10- - ** Example:**
6+ - ** Usage:**
7+
8+ Sets ` Wrapper ` ` vm ` props and forces update.
9+
10+ ** Note the Wrapper must contain a Vue instance.**
1111
1212``` js
1313import { mount } from ' vue-test-utils'
@@ -16,5 +16,33 @@ import Foo from './Foo.vue'
1616
1717const wrapper = mount (Foo)
1818wrapper .setProps ({ foo: ' bar' })
19- expect (wrapper .props ().foo ).toBe (' bar' )
19+ expect (wrapper .vm .foo ).to .equal (' bar' )
20+ ```
21+
22+ You can also pass a ` propsData ` object, which will initialize the Vue instance with passed values.
23+
24+ ``` js
25+ // Foo.vue
26+ export default {
27+ props: {
28+ foo: {
29+ type: String ,
30+ required: true
31+ }
32+ }
33+ }
34+ ```
35+
36+ ``` js
37+ import { mount } from ' vue-test-utils'
38+ import { expect } from ' chai'
39+ import Foo from ' ./Foo.vue'
40+
41+ const wrapper = mount (Foo, {
42+ propsData: {
43+ foo: ' bar'
44+ }
45+ })
46+
47+ expect (wrapper .vm .foo ).to .equal (' bar' )
2048```
You can’t perform that action at this time.
0 commit comments