Skip to content

Commit 687f5c8

Browse files
authored
docs(cn): translation part of the missing content (#937)
* docs(cn): translation part of the missing content * fix: miss links * docs(cn)L update guide/migration * fix: guide/improving-performance miss heading * docs(cn): update config.ts * docs(cn): update guide/improving-performance * typo * fix: guide/lifecycle * typo
1 parent 356db82 commit 687f5c8

19 files changed

Lines changed: 130 additions & 1500 deletions
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
22
<Badge type="danger">
3-
deprecated
3+
弃用
44
</Badge>
55
</template>

.vitepress/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ export default ({ mode }: { mode: string }) => {
777777
link: '/guide/environment',
778778
},
779779
{
780-
text: 'Test Run Lifecycle',
780+
text: '测试运行生命周期',
781781
link: '/guide/lifecycle',
782782
},
783783
{
@@ -885,7 +885,7 @@ export default ({ mode }: { mode: string }) => {
885885
link: '/guide/migration#jest',
886886
},
887887
{
888-
text: 'Migrating from Mocha + Chai + Sinon',
888+
text: 'Mocha + Chai + Sinon 迁移',
889889
link: '/guide/migration#mocha-chai-sinon',
890890
},
891891
],

api/advanced/runner.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,19 +279,17 @@ Vitest 提供了 `createTaskCollector` 工具来创建您自己的 `test` 方法
279279

280280
任务是套件的一部分对象。它会通过 `suite.task` 方法自动添加到当前套件中:
281281

282-
<!-- TODO: translation -->
283-
284282
```js [custom.js]
285283
export { afterAll, beforeAll, describe, TestRunner } from 'vitest'
286284

287-
// this function will be called during collection phase:
288-
// don't call function handler here, add it to suite tasks
289-
// with "getCurrentSuite().task()" method
290-
// note: createTaskCollector provides support for "todo"/"each"/...
285+
// 此函数将在收集阶段被调用:
286+
// 不要在此处调用函数处理器,而应通过
287+
// "getCurrentSuite().task()" 方法将其添加到套件任务中
288+
// 注意:createTaskCollector 提供了对 "todo"/"each"/... 的支持
291289
export const myCustomTask = TestRunner.createTaskCollector(
292290
function (name, fn, timeout) {
293291
TestRunner.getCurrentSuite().task(name, {
294-
...this, // so "todo"/"skip"/... is tracked correctly
292+
...this, // 以便正确追踪 "todo"/"skip"/...
295293
meta: {
296294
customPropertyToDifferentiateTask: true
297295
},

api/advanced/test-case.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,13 @@ test('the validation works correctly', ({ task }) => {
143143
task.meta.decorated = false
144144
})
145145
```
146-
<!-- TODO: translation reference history -->
147-
148-
If the test did not finish running yet, the meta will be an empty object, unless it has static meta:
146+
如果测试尚未运行完毕,元数据将是一个空对象,除非它定义了静态元数据:
149147

150148
```ts
151149
test('the validation works correctly', { meta: { decorated: true } })
152150
```
153151

154-
Since Vitest 4.1, Vitest inherits [`meta`](/api/advanced/test-suite#meta) property defined on the [suite](/api/advanced/test-suite).
152+
Vitest 4.1 起,Vitest 会继承定义在 [套件](/api/advanced/test-suite) 上的 [`meta`](/api/advanced/test-suite#meta) 属性。
155153

156154
## result
157155

api/expect.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
type Awaitable<T> = T | PromiseLike<T>
77
```
88
9-
<!-- TODO: translation reference history -->
10-
11-
`expect` is used to create assertions. In this context `assertions` are functions that can be called to assert a statement. Vitest provides `chai` assertions by default and also `Jest` compatible assertions built on top of `chai`. Since Vitest 4.1, for spy/mock testing, Vitest also provides [Chai-style assertions](#chai-style-spy-assertions) (e.g., `expect(spy).to.have.been.called()`) alongside Jest-style assertions (e.g., `expect(spy).toHaveBeenCalled()`). Unlike `Jest`, Vitest supports a message as the second argument - if the assertion fails, the error message will be equal to it.
9+
`expect` 用于创建断言。在此上下文中,`断言` 是可以被调用来验证一个语句的函数。Vitest 默认提供 `chai` 断言,同时也提供基于 chai 构建的兼容 `Jest` 的断言。自 Vitest 4.1 起,在进行 spy/mock 测试时,Vitest 还额外提供了 [Chai 风格断言](#chai-style-spy-assertions)(如 `expect(spy).to.have.been.called()`),与 Jest 风格断言(如 `expect(spy).toHaveBeenCalled()`)并存。与 `Jest` 不同,Vitest 支持将一条消息作为第二个参数传入,如果断言失败,错误信息将等于该消息。
1210
1311
```ts
1412
export interface ExpectStatic extends Chai.ExpectStatic, AsymmetricMatchersContaining {
@@ -33,7 +31,7 @@ expect(input).to.equal(2) // chai API
3331
expect(input).toBe(2) // jest API
3432
```
3533

36-
从技术上讲,这个示例没有使用 [`test`](/api/#test) 函数,因此在控制台中你将看到 Nodejs 错误而不是 Vitest 输出。 要了解更多关于 `test` 的信息,请参阅 [Test API](/api/test)
34+
从技术上讲,这个示例没有使用 [`test`](/api/test) 函数,因此在控制台中你将看到 Nodejs 错误而不是 Vitest 输出。 要了解更多关于 `test` 的信息,请参阅 [Test API](/api/test)
3735

3836
此外,`expect` 可以静态地使用来访问匹配器函数,稍后将会介绍。
3937

@@ -792,9 +790,7 @@ test('the number of elements must match exactly', () => {
792790

793791
- `RegExp`: 错误消息匹配该模式
794792
- `string`: 错误消息包含该子字符串
795-
- any other value: compare with thrown value using deep equality (similar to `toEqual`)
796-
797-
<!-- TODO: translation -->
793+
- 任何其他值:使用深度相等与抛出的值进行比较(等价于 `toEqual`
798794

799795
:::tip
800796
必须将代码包装在一个函数中,否则错误将无法被捕获,测试将失败。
@@ -855,10 +851,8 @@ test('throws on pineapples', async () => {
855851

856852
:::
857853

858-
<!-- TODO: translation -->
859-
860854
:::tip
861-
You can also test non-Error values that are thrown:
855+
你也可以测试抛出的非 Error 值:
862856

863857
```ts
864858
test('throws non-Error values', () => {

0 commit comments

Comments
 (0)