File tree 3 files changed +57
-2
lines changed
3 files changed +57
-2
lines changed Original file line number Diff line number Diff line change @@ -24,3 +24,58 @@ import VueTestUtils from '@vue/test-utils'
24
24
25
25
VueTestUtils .config .stubs [' my-component' ] = ' <div />'
26
26
```
27
+
28
+ ### ` mocks `
29
+
30
+ - 类型:` Object `
31
+ - 默认值:` {} `
32
+
33
+ 默认使用传递给 ` config.mocks ` 的值,类似 ` stubs ` 。传递给挂载选项中 ` mocks ` 对象的任何值都会优先于 ` config.mocks ` 中的同名声明。
34
+
35
+ 示例:
36
+
37
+ ``` js
38
+ import VueTestUtils from ' @vue/test-utils'
39
+
40
+ VueTestUtils .config .mocks [' $store' ] = {
41
+ state: {
42
+ id: 1
43
+ }
44
+ }
45
+ ```
46
+
47
+ ### ` methods `
48
+
49
+ - 类型:` Object `
50
+ - 默认值:` {} `
51
+
52
+ 你可以使用 ` config ` 对象配置默认的方法。它可以用于为组件注入方法的插件,例如 [ VeeValidate] ( https://vee-validate.logaretm.com/ ) 。你可以通过在挂载选项中传入 ` methods ` 来覆写 ` config ` 中的方法集合。
53
+
54
+ 示例:
55
+
56
+ ``` js
57
+ import VueTestUtils from ' @vue/test-utils'
58
+
59
+ VueTestUtils .config .methods [' errors' ] = () => {
60
+ any : () => false
61
+ }
62
+ ```
63
+
64
+ ### ` provide `
65
+
66
+ - 类型:` Object `
67
+ - 默认值:` {} `
68
+
69
+ 默认使用传递给 ` config.provide ` 的值,类似 ` stubs ` 或 ` mocks ` 。传递给挂载选项中 ` provide ` 对象的任何值都会优先于 ` config.provide ` 中的同名声明。** 请注意这里不支持将函数传递给 ` config.provide ` 。**
70
+
71
+ 示例:
72
+
73
+ ``` js
74
+ import VueTestUtils from ' @vue/test-utils'
75
+
76
+ VueTestUtils .config .provide [' $logger' ] = {
77
+ log : (... args ) => {
78
+ console .log (... args)
79
+ }
80
+ }
81
+ ```
Original file line number Diff line number Diff line change 1
- # ` mount(component { , options} ]) `
1
+ # ` mount(component [ , options]) `
2
2
3
3
- ** 参数:**
4
4
Original file line number Diff line number Diff line change 6
6
7
7
- [ ` context ` ] ( #context )
8
8
- [ ` slots ` ] ( #slots )
9
- - [ scopedSlots] ( #scopedslots )
9
+ - [ ` scopedSlots ` ] ( #scopedslots )
10
10
- [ ` stubs ` ] ( #stubs )
11
11
- [ ` mocks ` ] ( #mocks )
12
12
- [ ` localVue ` ] ( #localvue )
You can’t perform that action at this time.
0 commit comments