Skip to content
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

docs(zh): review migration #2623

Merged
merged 5 commits into from
Feb 28, 2025
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
2 changes: 1 addition & 1 deletion docs/.vitepress/config/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export default defineConfig({
locales: {
root: { label: 'English', lang: 'en-US', link: '/', ...enConfig },
fr: { label: 'Français', lang: 'fr-FR', link: '/fr/', ...frConfig },
zh: { label: '简体中文 (校对中)', lang: 'zh-CN', link: '/zh/', ...zhConfig }
zh: { label: '简体中文', lang: 'zh-CN', link: '/zh/', ...zhConfig }
}
})
2 changes: 1 addition & 1 deletion docs/.vitepress/config/zh.mts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const zhConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
link: '/zh/guide/advanced/teleport'
},
{
text: 'Stubs 和浅挂载',
text: '测试替身 (stub) 和浅挂载',
link: '/zh/guide/advanced/stubs-shallow-mount'
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/theme/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import status from '../translation-status.json'
import './custom.css'
const i18nLabels = {
fr: 'La traduction est synchronisée avec les docs du ${date} dont le hash du commit est <code>${hash}</code>.',
zh: '该翻译已同步到了 ${date} 的版本,其对应的 commit hash 是 <code>${hash}</code>。<br /><mark>同时该文档仍处于校对中,如有任何疑问或想参与校对工作,请<a href="https://github.com/vuejs/test-utils/issues/2561" target="_blank" style="font-weight: bold; text-decoration: underline;">移步这里</a>了解更多。</mark>'
zh: '该翻译已同步到了 ${date} 的版本,其对应的 commit hash 是 <code>${hash}</code>。'
}


Expand Down
8 changes: 4 additions & 4 deletions docs/zh/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ test('global.renderStubDefaultSlot', () => {

#### global.stubs

在挂载的组件上使用全局替代组件 (stub)。
在挂载的组件上使用全局测试替身 (stub)。

**签名:**

Expand All @@ -726,7 +726,7 @@ stubs?: Record<any, any>

**详细信息:**

默认情况下,`Transition` 和 `TransitionGroup` 组件会被自动 stub 掉
默认情况下,`Transition` 和 `TransitionGroup` 组件会被自动创建测试替身

`Component.vue`:

Expand Down Expand Up @@ -788,7 +788,7 @@ test('global.stubs using a custom component', () => {

### shallow

组件的所有子组件替换为 stub
组件的所有子组件替换为测试替身

**签名:**

Expand Down Expand Up @@ -1893,7 +1893,7 @@ function shallowMount(Component, options?: MountingOptions): VueWrapper

**详细信息:**

`shallowMount` 的行为与 `mount` 完全相同,但它默认会 stub (替代) 所有的子组件。实际上,`shallowMount(Component)` 是 `mount(Component, { shallow: true })` 的别名。
`shallowMount` 的行为与 `mount` 完全相同,但它默认为所有的子组件创建测试替身。实际上,`shallowMount(Component)` 是 `mount(Component, { shallow: true })` 的别名。

## enableAutoUnmount

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/guide/advanced/stubs-shallow-mount.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ test('stubs component', () => {
这将为整个渲染树中的*所有* `<FetchDataFromApi />` 组件创建测试替身,而不管它们出现在哪个层级。这就是为什么它在 `global` 挂载选项中的原因。

::: tip
要桩化组件,你可以使用 `components` 中的键或组件的名称。如果在 `global.stubs` 中同时给出这两者,将优先使用键。
要为组件创建测试替身,你可以使用 `components` 中的键或组件的名称。如果在 `global.stubs` 中同时给出这两者,将优先使用键。
:::

## 为所有子组件创建测试替身
Expand Down
8 changes: 4 additions & 4 deletions docs/zh/guide/advanced/transitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default {
</style>
```

由于 Vue Test Utils 会模拟内置的过渡效果,你可以像测试其他组件一样测试上述组件:
由于 Vue Test Utils 会为内置的 transition 组件创建测试替身,你可以像测试其他组件一样测试上述组件:

```js
import Component from './Component.vue'
Expand All @@ -60,11 +60,11 @@ test('works with transitions', async () => {

## 部分支持

Vue Test Utils 内置的过渡效果模拟比较简单,并不涵盖 Vue 所有的[过渡特性](https://vuejs.org/guide/built-ins/transition)。例如它不支持 [JavaScript 钩子](https://vuejs.org/guide/built-ins/transition#javascript-hooks)。这一限制可能会导致 Vue 发出警告。
Vue Test Utils 内置的 transition 组件的测试替身比较简单,并不涵盖 Vue 所有的[过渡特性](https://vuejs.org/guide/built-ins/transition)。例如它不支持 [JavaScript 钩子](https://vuejs.org/guide/built-ins/transition#javascript-hooks)。这一限制可能会导致 Vue 发出警告。

::: tip
潜在解决方案:
- 你可以通过将 [global stubs transition](../../api/#global-stubs) 设置为 false 来关闭自动模拟
- 如果需要,你可以自行模拟过渡效果,以处理这些钩子。
- 你可以通过将[全局 transition 测试替身](../../api/#global-stubs) 设置为 false 来停止自从创建测试替身
- 如果需要,你可以自行创建 transition 的测试替身,以处理这些钩子。
- 你可以在测试中捕获警告以消除它。
:::
2 changes: 1 addition & 1 deletion docs/zh/guide/faq/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ TypeError: Cannot set property prefix of #<Element> which has only a getter

**可能的解决方案**

1. 使用 `mount` 而不是 `shallowMount` 进行不带存根的渲染
1. 使用 `mount` 而不是 `shallowMount` 进行不带测试替身的渲染
2. 通过模拟 `console.warn` 来忽略警告
3. 重命名 prop,以避免与 `Element` 属性冲突
Loading