Skip to content

Commit d90e731

Browse files
authored
docs(v3): update /api/index (#936)
* docs(v3): update /api/index * typo * docs(v3): update /api/index * typo * docs(cn): update /api/expect * docs(v3): update config/watchtriggerpatterns * typo * typo * typo * typo * revert advanced/api/reporters.md
1 parent 9163c1a commit d90e731

4 files changed

Lines changed: 62 additions & 61 deletions

File tree

advanced/reporters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import { DefaultReporter } from 'vitest/reporters'
1515

1616
export default class MyDefaultReporter extends DefaultReporter {
17-
// do something
17+
// 执行操作
1818
}
1919
```
2020

@@ -40,7 +40,7 @@ import type { Reporter } from 'vitest/node'
4040

4141
export default class CustomReporter implements Reporter {
4242
onTestModuleCollected() {
43-
// print something
43+
// 打印内容
4444
}
4545
}
4646
```

api/expect.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ test('matches snapshot', () => {
792792
})
793793
```
794794

795-
我们还可以提供一个对象的形状,如果我们只是测试对象的形状,而不需要它完全兼容
795+
当我们不需要完全兼容时,可以仅对对象的接口规范进行测试
796796

797797
```ts
798798
import { expect, test } from 'vitest'
@@ -828,7 +828,7 @@ test('matches inline snapshot', () => {
828828
})
829829
```
830830

831-
如果我么只是在测试对象的形状,而不需要它 100% 兼容,我们也可以提供一个对象的形状。
831+
当我们不需要完全兼容时,可以仅对对象的接口规范进行测试:
832832

833833
```ts
834834
import { expect, test } from 'vitest'
@@ -1552,7 +1552,7 @@ test('basket includes fuji', () => {
15521552

15531553
- **类型:** `(expected: any) => any`
15541554

1555-
当与相等检查一起使用时,如果值的形状相似,该非对称匹配器将返回 `true`
1555+
当与相等检查一起使用时,如果值的接口规范相似,该非对称匹配器将返回 `true`
15561556

15571557
```ts
15581558
import { expect, test } from 'vitest'

api/index.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ test.runIf(isDev)('dev only test', () => {
235235
- **类型:** `(name: string | Function, fn: TestFunction, timeout?: number) => void`
236236
- **别名:** `it.only`
237237

238-
使用 `test.only` 仅运行给定 测试套件 中的某些测试。这在调试时非常有用。
238+
使用 `test.only` 仅运行给定测试套件中的某些测试。这在调试时非常有用。
239239

240240
可选择提供超时(以毫秒为单位),用于指定终止前的等待时间。默认值为 5 秒,可通过 [testTimeout](/config/#testtimeout) 进行全局配置。
241241

@@ -284,9 +284,9 @@ describe('suite', () => {
284284

285285
```ts
286286
test.concurrent(/* ... */)
287-
test.skip.concurrent(/* ... */) // or test.concurrent.skip(/* ... */)
288-
test.only.concurrent(/* ... */) // or test.concurrent.only(/* ... */)
289-
test.todo.concurrent(/* ... */) // or test.concurrent.todo(/* ... */)
287+
test.skip.concurrent(/* ... */) // test.concurrent.skip(/* ... */)
288+
test.only.concurrent(/* ... */) // test.concurrent.only(/* ... */)
289+
test.todo.concurrent(/* ... */) // test.concurrent.todo(/* ... */)
290290
```
291291

292292
运行并发测试时,快照和断言必须使用本地 [测试上下文](/guide/test-context.md) 中的 `expect`,以确保检测到正确的测试。
@@ -376,15 +376,15 @@ test.fails('fail test', async () => {
376376
当需要使用不同变量运行同一测试时,请使用 `test.each`
377377
我们可以按照测试功能参数的顺序,在测试名称中注入带有 [printf formatting](https://nodejs.org/api/util.html#util_util_format_format_args) 的参数。
378378

379-
- `%s`: string
380-
- `%d`: number
381-
- `%i`: integer
382-
- `%f`: floating point value
383-
- `%j`: json
384-
- `%o`: object
385-
- `%#`: 0-based index of the test case
386-
- `%$`: 1-based index of the test case
387-
- `%%`: single percent sign ('%')
379+
- `%s`:字符串
380+
- `%d`:数字
381+
- `%i`:整数
382+
- `%f`:浮点数
383+
- `%j`:JSON
384+
- `%o`:对象
385+
- `%#`:测试用例从 0 开始的索引
386+
- `%$`:测试用例从 1 开始的索引
387+
- `%%`:百分号字面量(`%`
388388

389389
```ts
390390
import { expect, test } from 'vitest'
@@ -480,7 +480,7 @@ Vitest 使用 chai `format` 方法处理 `$values`。如果数值太短,可以
480480

481481
`test.each` 是一种能同时提供 [`TestContext`](/guide/test-context) 的替代用法。
482482

483-
它和 `test.each` 的主要区别在于:当你需要传递数组参数时,二者的写法和处理方式不同。而对于非数组参数(包括模板字符串的用法),`test.each``test.each` 的使用方法是一致的。
483+
它和 `test.each` 的主要区别在于:当你需要传递数组参数时,二者的写法和处理方式不同。而对于非数组参数(包括模板字符串的用法),`test.for``test.each` 的使用方法是一致的。
484484

485485
```ts
486486
// `each` 展开数组用例
@@ -889,7 +889,7 @@ import { assert, describe, test } from 'vitest'
889889
const isDev = process.env.NODE_ENV === 'development'
890890

891891
describe.runIf(isDev)('dev only test suite', () => {
892-
// 此测试套件仅在开发环境中运行
892+
// 此测试套件仅在开发环境中运行
893893
})
894894
```
895895

@@ -906,7 +906,7 @@ describe.runIf(isDev)('dev only test suite', () => {
906906
```ts
907907
import { assert, describe, test } from 'vitest'
908908

909-
// 只有此测试套件(以及其他标记为 `only` 的测试套件)会被运行
909+
// 只有此测试套件(以及其他标记为 `only` 的测试套件)会被运行
910910
describe.only('suite', () => {
911911
test('sqrt', () => {
912912
assert.equal(Math.sqrt(4), 3)
@@ -1161,7 +1161,7 @@ describe.for([
11611161
import { beforeEach } from 'vitest'
11621162

11631163
beforeEach(async () => {
1164-
// 每次执行测试前,先重置所有 mock,然后准备好需要用到的测试数据
1164+
// 每次执行测试前,先重置所有 mock,然后准备好需要用到的测试数据
11651165
await stopMocking()
11661166
await addUser({ name: 'John' })
11671167
})
@@ -1175,10 +1175,10 @@ beforeEach(async () => {
11751175
import { beforeEach } from 'vitest'
11761176

11771177
beforeEach(async () => {
1178-
// 在每个测试运行之前调用一次
1178+
// 在每个测试运行之前调用一次
11791179
await prepareSomething()
11801180

1181-
// 清理函数,在每个测试运行之后调用一次
1181+
// 清理函数,在每个测试运行之后调用一次
11821182
return async () => {
11831183
await resetSomething()
11841184
}

0 commit comments

Comments
 (0)