From 1af49f32ac6f83b38ef2f8f256adb42034b2fb0e Mon Sep 17 00:00:00 2001 From: wuzhiqing Date: Wed, 4 Dec 2024 07:04:36 +0000 Subject: [PATCH] feat: update Co-authored-by: veaba Co-authored-by: Jinjiang --- docs/zh/guide/advanced/reusability-composition.md | 2 +- docs/zh/guide/advanced/vue-router.md | 4 ++-- docs/zh/migration/index.md | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/zh/guide/advanced/reusability-composition.md b/docs/zh/guide/advanced/reusability-composition.md index 16efb046d..b08c7f4de 100644 --- a/docs/zh/guide/advanced/reusability-composition.md +++ b/docs/zh/guide/advanced/reusability-composition.md @@ -51,7 +51,7 @@ export function useUser(userId) { } ``` -要测试这个组合式函数,你可以在测试中创建一个简单的 `TestComponent`。`TestComponent` 应该以与真实组件相同的方式使用组合式函数。 +要测试这个组合式函数,你可以在测试中创建一个简单的 `TestComponent`。`TestComponent` 应该与真实组件相同的方式使用组合式函数。 ```typescript // 模拟 API 请求 diff --git a/docs/zh/guide/advanced/vue-router.md b/docs/zh/guide/advanced/vue-router.md index ca2220058..0c70483d9 100644 --- a/docs/zh/guide/advanced/vue-router.md +++ b/docs/zh/guide/advanced/vue-router.md @@ -286,7 +286,7 @@ console.error node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:211 同样,由于 Vue Router 4 的新异步特性,我们需要在进行任何断言之前 `await` 路由完成。 -然而,在这种情况下,我们没有可以等待的 _hasNavigated_ 钩子。一种替代方法是使用从 Vue Test Utils 导出的 `flushPromises` 函数: +然而,在这种情况下,我们没有可以等待的 *hasNavigated* 钩子。一种替代方法是使用从 Vue Test Utils 导出的 `flushPromises` 函数: ```js {1,22} import { mount, flushPromises } from '@vue/test-utils' @@ -315,7 +315,7 @@ test('routing', async () => { }) ``` -它*终于*通过了。太好了!然而,这一切都非常手动——而且这是针对一个微小且无关紧要的应用程序。这就是在使用 Vue Test Utils 测试 Vue 组件时,使用模拟路由器是一种常见方法的原因。如果你倾向于继续使用真实的路由器,请记住每个测试都应该使用自己实例化的路由器,如下所示: +它_终于_通过了。太好了!然而,这一切都非常手动——而且这是针对一个微小且无关紧要的应用程序。这就是在使用 Vue Test Utils 测试 Vue 组件时,使用模拟路由器是一种常见方法的原因。如果你倾向于继续使用真实的路由器,请记住每个测试都应该使用自己实例化的路由器,如下所示: ```js {1,19} import { mount, flushPromises } from '@vue/test-utils' diff --git a/docs/zh/migration/index.md b/docs/zh/migration/index.md index 77395f369..800333641 100644 --- a/docs/zh/migration/index.md +++ b/docs/zh/migration/index.md @@ -330,6 +330,7 @@ module.exports = { 如果你使用快照测试并且注释节点泄漏到你的快照中,请注意 `comments` 现在始终[保留](https://vuejs.org/api/application.html#app-config-compileroptions-comments),并仅在生产中删除。你可以通过调整 `app.config.compilerOptions` 来覆盖此行为,以便在快照中也删除它们: - 通过 `vue-jest`[配置](https://github.com/vuejs/vue-jest#compiler-options-in-vue-3)。 + ```js // jest.config.js module.exports = { @@ -342,11 +343,12 @@ module.exports = { } } ``` + - 通过 `@vue/test-utils` [`mountingOptions.global.config`](https://test-utils.vuejs.org/api/#global) 全局或逐个测试基础。 ## 与 v1 的比较 -这是一个针对来自 VTU 1 的用户的表格,比较 API。 +这是一个针对来自 VTU 1 用户的表格,其比较了两者的 API。 ### 基础 API