Skip to content

Commit 79854cb

Browse files
Jinjiangeddyerburgh
authored andcommitted
docs: updated f3d4086...b555477 (#575)
1 parent f689640 commit 79854cb

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

Diff for: docs/zh-cn/api/config.md

+55
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,58 @@ import VueTestUtils from '@vue/test-utils'
2424

2525
VueTestUtils.config.stubs['my-component'] = '<div />'
2626
```
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+
```

Diff for: docs/zh-cn/api/mount.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `mount(component {, options}])`
1+
# `mount(component [, options])`
22

33
- **参数:**
44

Diff for: docs/zh-cn/api/options.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
- [`context`](#context)
88
- [`slots`](#slots)
9-
- [scopedSlots](#scopedslots)
9+
- [`scopedSlots`](#scopedslots)
1010
- [`stubs`](#stubs)
1111
- [`mocks`](#mocks)
1212
- [`localVue`](#localvue)

0 commit comments

Comments
 (0)