Skip to content

docs(zh): updated #1194

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 2 commits into from
Apr 23, 2019
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
11 changes: 10 additions & 1 deletion docs/zh/api/options.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# 挂载选项

即 `mount` 和 `shallowMount` 的选项。该对象同时包含了 Vue Test Utils 挂载选项和其它选项。
`mount` 和 `shallowMount` 的选项。

:::tip
除了下方列出的选项,`options` 对象还可以包含任何 `new Vue ({ /*options here*/ })` 调用时的有效选项。
当通过 `mount` / `shallowMount` 挂载时,这些选项将会合并入组件现有的选项中。

[查阅其它选项的例子](#其它选项)
:::

- [`context`](#context)
- [`slots`](#slots)
Expand Down Expand Up @@ -199,6 +206,8 @@ expect(wrapper.vm.$route).toBeInstanceOf(Object)

当设为 `true` 时,组件在渲染时将会挂载到 DOM 上。

如果添加到了 DOM 上,你应该在测试的最后调用 `wrapper.destroy()` 将元素从文档中移除并销毁组件实例。

## attrs

- 类型:`Object`
Expand Down
4 changes: 4 additions & 0 deletions docs/zh/api/wrapper/destroy.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ mount({
}).destroy()
expect(spy.calledOnce).toBe(true)
```

如果挂载时 `attachToDocument` 被设为 `true`,则组件的 DOM 元素也将会从文档中被移除。

对于函数式组件来说,`destroy` 只会从文档中移除渲染出来的 DOM 元素。
2 changes: 1 addition & 1 deletion docs/zh/guides/testing-single-file-components-with-jest.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Jest 可以被用来生成多种格式的测试覆盖率报告。以下是一个

### 测试规范示例

如果你已经熟悉了 Jasmine,你应该很适应 Jest 的[断言 API](https://jestjs.io/docs/zh-Hans/expect.htm):
如果你已经熟悉了 Jasmine,你应该很适应 Jest 的[断言 API](https://jestjs.io/docs/zh-Hans/expect):

```js
import { mount } from '@vue/test-utils'
Expand Down