@@ -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
286286test .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
390390import { 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'
889889const isDev = process .env .NODE_ENV === ' development'
890890
891891describe .runIf (isDev )(' dev only test suite' , () => {
892- // 此测试套件仅在开发环境中运行。
892+ // 此测试套件仅在开发环境中运行
893893})
894894```
895895
@@ -906,7 +906,7 @@ describe.runIf(isDev)('dev only test suite', () => {
906906``` ts
907907import { assert , describe , test } from ' vitest'
908908
909- // 只有此测试套件(以及其他标记为 `only` 的测试套件)会被运行。
909+ // 只有此测试套件(以及其他标记为 `only` 的测试套件)会被运行
910910describe .only (' suite' , () => {
911911 test (' sqrt' , () => {
912912 assert .equal (Math .sqrt (4 ), 3 )
@@ -1161,7 +1161,7 @@ describe.for([
11611161import { beforeEach } from ' vitest'
11621162
11631163beforeEach (async () => {
1164- // 每次执行测试前,先重置所有 mock,然后准备好需要用到的测试数据。
1164+ // 每次执行测试前,先重置所有 mock,然后准备好需要用到的测试数据
11651165 await stopMocking ()
11661166 await addUser ({ name: ' John' })
11671167})
@@ -1175,10 +1175,10 @@ beforeEach(async () => {
11751175import { beforeEach } from ' vitest'
11761176
11771177beforeEach (async () => {
1178- // 在每个测试运行之前调用一次。
1178+ // 在每个测试运行之前调用一次
11791179 await prepareSomething ()
11801180
1181- // 清理函数,在每个测试运行之后调用一次。
1181+ // 清理函数,在每个测试运行之后调用一次
11821182 return async () => {
11831183 await resetSomething ()
11841184 }
0 commit comments