File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 11# 挂载选项
22
3- 即 ` mount ` 和 ` shallowMount ` 的选项。该对象同时包含了 Vue Test Utils 挂载选项和其它选项。
3+ ` mount ` 和 ` shallowMount ` 的选项。
4+
5+ ::: tip
6+ 除了下方列出的选项,` options ` 对象还可以包含任何 ` new Vue ({ /*options here*/ }) ` 调用时的有效选项。
7+ 当通过 ` mount ` / ` shallowMount ` 挂载时,这些选项将会合并入组件现有的选项中。
8+
9+ [ 查阅其它选项的例子] ( #其它选项 )
10+ :::
411
512- [ ` context ` ] ( #context )
613- [ ` slots ` ] ( #slots )
@@ -199,6 +206,8 @@ expect(wrapper.vm.$route).toBeInstanceOf(Object)
199206
200207当设为 ` true ` 时,组件在渲染时将会挂载到 DOM 上。
201208
209+ 如果添加到了 DOM 上,你应该在测试的最后调用 ` wrapper.destroy() ` 将元素从文档中移除并销毁组件实例。
210+
202211## attrs
203212
204213- 类型:` Object `
Original file line number Diff line number Diff line change @@ -17,3 +17,7 @@ mount({
1717}).destroy ()
1818expect (spy .calledOnce ).toBe (true )
1919```
20+
21+ 如果挂载时 ` attachToDocument ` 被设为 ` true ` ,则组件的 DOM 元素也将会从文档中被移除。
22+
23+ 对于函数式组件来说,` destroy ` 只会从文档中移除渲染出来的 DOM 元素。
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ Jest 可以被用来生成多种格式的测试覆盖率报告。以下是一个
155155
156156### 测试规范示例
157157
158- 如果你已经熟悉了 Jasmine,你应该很适应 Jest 的[ 断言 API] ( https://jestjs.io/docs/zh-Hans/expect.htm ) :
158+ 如果你已经熟悉了 Jasmine,你应该很适应 Jest 的[ 断言 API] ( https://jestjs.io/docs/zh-Hans/expect ) :
159159
160160``` js
161161import { mount } from ' @vue/test-utils'
You can’t perform that action at this time.
0 commit comments