File tree Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 11
11
12
12
## 什么是 Vue Test Utils?
13
13
14
- Vue Test Utils (VTU) 是一组实用函数,旨在简化对 Vue.js 组件的测试。它提供了一些方法来以独立的方式挂载和与 Vue 组件进行交互。
14
+ Vue Test Utils (VTU) 是一组实用函数,旨在简化 Vue.js 的组件测试。它提供了一些方法来独立地挂载 Vue 组件并与 Vue 组件进行交互。
15
15
16
16
让我们看一个例子:
17
17
@@ -31,25 +31,25 @@ test('displays message', () => {
31
31
}
32
32
})
33
33
34
- // 断言组件的渲染文本
34
+ // 断言组件渲染出的文本
35
35
expect (wrapper .text ()).toContain (' Hello world' )
36
36
})
37
37
```
38
38
39
- Vue Test Utils 通常与测试运行器一起使用 。流行的测试运行器包括:
39
+ Vue Test Utils 通常需要和一个测试运行器配合使用 。流行的测试运行器包括:
40
40
41
41
- [ Vitest] ( https://vitest.dev/ ) 。基于终端,具有实验性的浏览器 UI。
42
42
- [ Cypress] ( https://cypress.io/ ) 。基于浏览器,支持 Vite、webpack。
43
43
- [ Playwright] ( https://playwright.dev/docs/test-components ) (实验性) 基于浏览器,支持 Vite。
44
44
- [ WebdriverIO] ( https://webdriver.io/docs/component-testing/vue ) 。基于浏览器,支持 Vite、Webpack,跨浏览器支持。
45
45
46
- Vue Test Utils 是一个简单且不拘泥于特定风格的库的库。如果你希望使用更具功能性、易用性和明确意见的工具,可以考虑 [ Cypress 组件测试 ] ( https://docs.cypress.io/guides/component-testing/overview ) ,它具有热重载开发环境,或者 [ Testing Library] ( https://testing-library.com/docs/vue-testing-library/intro/ ) ,它在进行断言时强调可访问性选择器 (Accessibility) 。这两种工具在底层都使用 Vue Test Utils, 并暴露相同的 API。
46
+ Vue Test Utils 是最小化且不含偏见的库。如果你想要功能更丰富、更易用且偏好更鲜明的工具,获取可以考虑具有热重载开发环境的 [ Cypress Component Testing ] ( https://docs.cypress.io/guides/component-testing/overview ) 、或者在断言时强调基于可访问性选择器的 [ Testing Library] ( https://testing-library.com/docs/vue-testing-library/intro/ ) 。这两种工具在底层都使用 Vue Test Utils 并暴露相同的 API。
47
47
48
48
## 接下来做什么?
49
49
50
- 要查看 Vue Test Utils 的实际应用 ,请[ 查阅快速上手] ( ../guide/essentials/a-crash-course.md ) ,我们将使用测试优先的方法构建一个简单的待办事项应用 。
50
+ 要查看 Vue Test Utils 的实际运用 ,请[ 查阅快速上手] ( ../guide/essentials/a-crash-course.md ) ,在那里,我们使用测试优先的思路构建了一个简单的待办事项应用 。
51
51
52
- 文档分为两个主要部分 :
52
+ 我们的文档分为两个主要部分 :
53
53
54
54
- ** 基础知识** ,涵盖你在测试 Vue 组件时可能遇到的常见用例。
55
55
- ** 深入学习 Vue Test Utils** ,探索库的其他高级功能。
Original file line number Diff line number Diff line change 2
2
layout : home
3
3
4
4
title : Vue Test Utils
5
- titleTemplate : Vue Test Utils for Vue .js 3
5
+ titleTemplate : Vue.js 3 测试工具
6
6
7
7
hero :
8
8
name : Vue Test Utils
Original file line number Diff line number Diff line change @@ -14,9 +14,9 @@ yarn add --dev @vue/test-utils
14
14
15
15
## 用法
16
16
17
- Vue Test Utils 是与框架无关的 - 你可以与任何你喜欢的测试运行器一起使用。最简单的尝试方式是使用 [ Jest] ( https://jestjs.io/ ) ,这是一个流行的测试运行器。
17
+ Vue Test Utils 是与测试框架无关的—— 你可以与任何你喜欢的测试运行器一起使用。最简单的尝试方式是使用 [ Jest] ( https://jestjs.io/ ) ,这是一个流行的测试运行器。
18
18
19
- 要在 Jest 中加载 ` .vue ` 文件,你需要 ` vue-jest ` 。` vue-jest ` v5 是支持 Vue 3 的版本。它仍处于 alpha 阶段,就像 Vue.js 3 生态系统的其他部分一样,所以如果你发现错误, 请在[ 这里] ( https://github.com/vuejs/vue-jest/ ) 报告,并说明你正在使用 ` vue-jest ` v5。
19
+ 你需要 ` vue-jest ` 在 Jest 中加载 ` .vue ` 文件。` vue-jest ` v5 是支持 Vue 3 的版本。它和 Vue.js 3 生态系统的其他部分一样仍处于 alpha 阶段。如果你发现任何错误, 请在[ 这里] ( https://github.com/vuejs/vue-jest/ ) 报告,并注明你正在使用 ` vue-jest ` v5。
20
20
21
21
你可以通过 ` vue-jest@next ` 安装它。然后,你需要使用 Jest 的 [ transform] ( https://jestjs.io/docs/en/configuration#transform-objectstring-pathtotransformer--pathtotransformer-object ) 选项进行配置。
22
22
You can’t perform that action at this time.
0 commit comments