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 1111
1212## 什么是 Vue Test Utils?
1313
14- Vue Test Utils (VTU) 是一组实用函数,旨在简化对 Vue.js 组件的测试。它提供了一些方法来以独立的方式挂载和与 Vue 组件进行交互。
14+ Vue Test Utils (VTU) 是一组实用函数,旨在简化 Vue.js 的组件测试。它提供了一些方法来独立地挂载 Vue 组件并与 Vue 组件进行交互。
1515
1616让我们看一个例子:
1717
@@ -31,25 +31,25 @@ test('displays message', () => {
3131 }
3232 })
3333
34- // 断言组件的渲染文本
34+ // 断言组件渲染出的文本
3535 expect (wrapper .text ()).toContain (' Hello world' )
3636})
3737```
3838
39- Vue Test Utils 通常与测试运行器一起使用 。流行的测试运行器包括:
39+ Vue Test Utils 通常需要和一个测试运行器配合使用 。流行的测试运行器包括:
4040
4141- [ Vitest] ( https://vitest.dev/ ) 。基于终端,具有实验性的浏览器 UI。
4242- [ Cypress] ( https://cypress.io/ ) 。基于浏览器,支持 Vite、webpack。
4343- [ Playwright] ( https://playwright.dev/docs/test-components ) (实验性) 基于浏览器,支持 Vite。
4444- [ WebdriverIO] ( https://webdriver.io/docs/component-testing/vue ) 。基于浏览器,支持 Vite、Webpack,跨浏览器支持。
4545
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。
4747
4848## 接下来做什么?
4949
50- 要查看 Vue Test Utils 的实际应用 ,请[ 查阅快速上手] ( ../guide/essentials/a-crash-course.md ) ,我们将使用测试优先的方法构建一个简单的待办事项应用 。
50+ 要查看 Vue Test Utils 的实际运用 ,请[ 查阅快速上手] ( ../guide/essentials/a-crash-course.md ) ,在那里,我们使用测试优先的思路构建了一个简单的待办事项应用 。
5151
52- 文档分为两个主要部分 :
52+ 我们的文档分为两个主要部分 :
5353
5454- ** 基础知识** ,涵盖你在测试 Vue 组件时可能遇到的常见用例。
5555- ** 深入学习 Vue Test Utils** ,探索库的其他高级功能。
Original file line number Diff line number Diff line change 22layout : home
33
44title : Vue Test Utils
5- titleTemplate : Vue Test Utils for Vue .js 3
5+ titleTemplate : Vue.js 3 测试工具
66
77hero :
88 name : Vue Test Utils
Original file line number Diff line number Diff line change @@ -14,9 +14,9 @@ yarn add --dev @vue/test-utils
1414
1515## 用法
1616
17- Vue Test Utils 是与框架无关的 - 你可以与任何你喜欢的测试运行器一起使用。最简单的尝试方式是使用 [ Jest] ( https://jestjs.io/ ) ,这是一个流行的测试运行器。
17+ Vue Test Utils 是与测试框架无关的—— 你可以与任何你喜欢的测试运行器一起使用。最简单的尝试方式是使用 [ Jest] ( https://jestjs.io/ ) ,这是一个流行的测试运行器。
1818
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。
2020
2121你可以通过 ` vue-jest@next ` 安装它。然后,你需要使用 Jest 的 [ transform] ( https://jestjs.io/docs/en/configuration#transform-objectstring-pathtotransformer--pathtotransformer-object ) 选项进行配置。
2222
You can’t perform that action at this time.
0 commit comments