Skip to content

[docs][zh-cn] updated f3d4086...b555477 #575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions docs/zh-cn/api/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,58 @@ import VueTestUtils from '@vue/test-utils'

VueTestUtils.config.stubs['my-component'] = '<div />'
```

### `mocks`

- 类型:`Object`
- 默认值:`{}`

默认使用传递给 `config.mocks` 的值,类似 `stubs`。传递给挂载选项中 `mocks` 对象的任何值都会优先于 `config.mocks` 中的同名声明。

示例:

```js
import VueTestUtils from '@vue/test-utils'

VueTestUtils.config.mocks['$store'] = {
state: {
id: 1
}
}
```

### `methods`

- 类型:`Object`
- 默认值:`{}`

你可以使用 `config` 对象配置默认的方法。它可以用于为组件注入方法的插件,例如 [VeeValidate](https://vee-validate.logaretm.com/)。你可以通过在挂载选项中传入 `methods` 来覆写 `config` 中的方法集合。

示例:

```js
import VueTestUtils from '@vue/test-utils'

VueTestUtils.config.methods['errors'] = () => {
any: () => false
}
```

### `provide`

- 类型:`Object`
- 默认值:`{}`

默认使用传递给 `config.provide` 的值,类似 `stubs` 或 `mocks`。传递给挂载选项中 `provide` 对象的任何值都会优先于 `config.provide` 中的同名声明。**请注意这里不支持将函数传递给 `config.provide`。**

示例:

```js
import VueTestUtils from '@vue/test-utils'

VueTestUtils.config.provide['$logger'] = {
log: (...args) => {
console.log(...args)
}
}
```
2 changes: 1 addition & 1 deletion docs/zh-cn/api/mount.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `mount(component {, options}])`
# `mount(component [, options])`

- **参数:**

Expand Down
2 changes: 1 addition & 1 deletion docs/zh-cn/api/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

- [`context`](#context)
- [`slots`](#slots)
- [scopedSlots](#scopedslots)
- [`scopedSlots`](#scopedslots)
- [`stubs`](#stubs)
- [`mocks`](#mocks)
- [`localVue`](#localvue)
Expand Down