From 433a2f86bfeeb69f8b320c7a5460ffd6c1573dac Mon Sep 17 00:00:00 2001 From: msmx-mnakagawa Date: Mon, 26 Jan 2026 21:57:37 +0900 Subject: [PATCH 1/3] chore: fix typos in docs and comments (#9527) --- api/advanced/runner.md | 2 +- guide/parallelism.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/advanced/runner.md b/api/advanced/runner.md index acbf384b..514336b7 100644 --- a/api/advanced/runner.md +++ b/api/advanced/runner.md @@ -41,7 +41,7 @@ export interface VitestRunner { */ onAfterTryTask?: (test: Test, options: { retry: number; repeats: number }) => unknown /** - * Called after the retry resolution happend. Unlike `onAfterTryTask`, the test now has a new state. + * Called after the retry resolution happened. Unlike `onAfterTryTask`, the test now has a new state. * All `after` hooks were also called by this point. */ onAfterRetryTask?: (test: Test, options: { retry: number; repeats: number }) => unknown diff --git a/guide/parallelism.md b/guide/parallelism.md index ce866bf6..518e2d9d 100644 --- a/guide/parallelism.md +++ b/guide/parallelism.md @@ -12,7 +12,7 @@ By default, Vitest runs _test files_ in parallel. Depending on the specified `po - `forks` (the default) and `vmForks` run tests in different [child processes](https://nodejs.org/api/child_process.html) - `threads` and `vmThreads` run tests in different [worker threads](https://nodejs.org/api/worker_threads.html) -Both "child processes" and "worker threads" are refered to as "workers". You can configure the number of running workers with [`maxWorkers`](/config/#maxworkers) option. +Both "child processes" and "worker threads" are referred to as "workers". You can configure the number of running workers with [`maxWorkers`](/config/#maxworkers) option. If you have a lot of tests, it is usually faster to run them in parallel, but it also depends on the project, the environment and [isolation](/config/#isolate) state. To disable file parallelisation, you can set [`fileParallelism`](/config/#fileparallelism) to `false`. To learn more about possible performance improvements, read the [Performance Guide](/guide/improving-performance). From 4a2cb45c70fd529187caa33f464836923f2fd444 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Mon, 26 Jan 2026 15:05:26 +0100 Subject: [PATCH 2/3] feat: stabilize experimental features (#9529) --- api/advanced/reporters.md | 8 ++++---- api/advanced/test-module.md | 6 +++++- api/advanced/test-specification.md | 2 +- api/advanced/vitest.md | 4 +--- api/browser/context.md | 1 - guide/advanced/tests.md | 4 ---- guide/environment.md | 2 +- guide/snapshot.md | 2 +- 8 files changed, 13 insertions(+), 16 deletions(-) diff --git a/api/advanced/reporters.md b/api/advanced/reporters.md index 4e2b8e5a..c4330e8f 100644 --- a/api/advanced/reporters.md +++ b/api/advanced/reporters.md @@ -15,7 +15,7 @@ Vitest has its own test run lifecycle. These are represented by reporter's metho - [`onHookStart(beforeAll)`](#onhookstart) - [`onHookEnd(beforeAll)`](#onhookend) - [`onTestCaseReady`](#ontestcaseready) - - [`onTestAnnotate`](#ontestannotate) 3.2.0 + - [`onTestCaseAnnotate`](#ontestcaseannotate) 3.2.0 - [`onTestCaseArtifactRecord`](#ontestcaseartifactrecord) 4.0.11 - [`onHookStart(beforeEach)`](#onhookstart) - [`onHookEnd(beforeEach)`](#onhookend) @@ -313,16 +313,16 @@ This method is called when the test has finished running or was just skipped. No At this point, [`testCase.result()`](/api/advanced/test-case#result) will have non-pending state. -## onTestAnnotate 3.2.0 {#ontestannotate} +## onTestCaseAnnotate 3.2.0 {#ontestcaseannotate} ```ts -function onTestAnnotate( +function onTestCaseAnnotate( testCase: TestCase, annotation: TestAnnotation, ): Awaitable ``` -The `onTestAnnotate` hook is associated with the [`context.annotate`](/guide/test-context#annotate) method. When `annotate` is invoked, Vitest serialises it and sends the same attachment to the main thread where reporter can interact with it. +The `onTestCaseAnnotate` hook is associated with the [`context.annotate`](/guide/test-context#annotate) method. When `annotate` is invoked, Vitest serialises it and sends the same attachment to the main thread where reporter can interact with it. If the path is specified, Vitest stores it in a separate directory (configured by [`attachmentsDir`](/config/#attachmentsdir)) and modifies the `path` property to reference it. diff --git a/api/advanced/test-module.md b/api/advanced/test-module.md index 4b002e60..15f15ad9 100644 --- a/api/advanced/test-module.md +++ b/api/advanced/test-module.md @@ -121,10 +121,14 @@ interface ImportDuration { } ``` -## viteEnvironment 4.0.15 {#viteenvironment} +## viteEnvironment 4.1.0 {#viteenvironment} This is a Vite's [`DevEnvironment`](https://vite.dev/guide/api-environment) that transforms all files inside of the test module. +::: details History +- `v4.0.15`: added as experimental +::: + ## toTestSpecification 4.1.0 {#totestspecification} ```ts diff --git a/api/advanced/test-specification.md b/api/advanced/test-specification.md index 7142bba9..f66a4aa0 100644 --- a/api/advanced/test-specification.md +++ b/api/advanced/test-specification.md @@ -40,7 +40,7 @@ The ID of the module in Vite's module graph. Usually, it's an absolute file path Instance of [`TestModule`](/api/advanced/test-module) associated with the specification. If test wasn't queued yet, this will be `undefined`. -## pool experimental {#pool} +## pool {#pool} The [`pool`](/config/#pool) in which the test module will run. diff --git a/api/advanced/vitest.md b/api/advanced/vitest.md index eafc027a..cdf94c58 100644 --- a/api/advanced/vitest.md +++ b/api/advanced/vitest.md @@ -478,9 +478,7 @@ function onCancel(fn: (reason: CancelReason) => Awaitable): () => void Register a handler that will be called when the test run is cancelled with [`vitest.cancelCurrentRun`](#cancelcurrentrun). -::: warning EXPERIMENTAL -Since 4.0.10, `onCancel` returns a teardown function that will remove the listener. -::: +Since 4.0.10, `onCancel` experimentally returns a teardown function that will remove the listener. Since 4.1.0 this behaviour is considered stable. ## onClose diff --git a/api/browser/context.md b/api/browser/context.md index c2112024..c6cf0f88 100644 --- a/api/browser/context.md +++ b/api/browser/context.md @@ -222,7 +222,6 @@ export const utils: { /** * Configures default options of `prettyDOM` and `debug` functions. * This will also affect `vitest-browser-{framework}` package. - * @experimental */ configurePrettyDOM(options: StringifyOptions): void /** diff --git a/guide/advanced/tests.md b/guide/advanced/tests.md index 81d7b572..a5c0e26f 100644 --- a/guide/advanced/tests.md +++ b/guide/advanced/tests.md @@ -27,10 +27,6 @@ for (const testModule of testModules) { } ``` -::: tip -[`TestModule`](/api/advanced/test-module), [`TestSuite`](/api/advanced/test-suite) and [`TestCase`](/api/advanced/test-case) APIs are not experimental and follow SemVer since Vitest 2.1. -::: - ## `createVitest` Creates a [Vitest](/api/advanced/vitest) instances without running tests. diff --git a/guide/environment.md b/guide/environment.md index eb7eaabd..6c06964e 100644 --- a/guide/environment.md +++ b/guide/environment.md @@ -49,7 +49,7 @@ import type { Environment } from 'vitest/runtime' export default { name: 'custom', viteEnvironment: 'ssr', - // optional - only if you support "experimental-vm" pool + // optional - only if you support "vmForks" or "vmThreads" pools async setupVM() { const vm = await import('node:vm') const context = vm.createContext() diff --git a/guide/snapshot.md b/guide/snapshot.md index ea42a057..1d5860d7 100644 --- a/guide/snapshot.md +++ b/guide/snapshot.md @@ -98,7 +98,7 @@ It will compare with the content of `./test/basic.output.html`. And can be writt ## Visual Snapshots -For visual regression testing of UI components and pages, Vitest provides built-in support through [browser mode](/guide/browser/) with the [`toMatchScreenshot()`](/api/browser/assertions#tomatchscreenshot-experimental) assertion: +For visual regression testing of UI components and pages, Vitest provides built-in support through [browser mode](/guide/browser/) with the [`toMatchScreenshot()`](/api/browser/assertions#tomatchscreenshot) assertion: ```ts import { expect, test } from 'vitest' From 8d83cadb75571d5b7297a95324f0959d9ca34ca4 Mon Sep 17 00:00:00 2001 From: noise Date: Tue, 27 Jan 2026 11:18:59 +0800 Subject: [PATCH 3/3] docs(cn): dissolve the conflict --- api/advanced/reporters.md | 29 ++--------------------------- api/advanced/runner.md | 5 ----- api/advanced/vitest.md | 7 +------ guide/advanced/tests.md | 7 ------- guide/environment.md | 6 +----- guide/parallelism.md | 4 ---- guide/snapshot.md | 8 ++------ 7 files changed, 6 insertions(+), 60 deletions(-) diff --git a/api/advanced/reporters.md b/api/advanced/reporters.md index 0cbab18d..64a8def0 100644 --- a/api/advanced/reporters.md +++ b/api/advanced/reporters.md @@ -6,26 +6,6 @@ Vitest 拥有自己的测试运行生命周期。这些生命周期通过报告器的方法来表示: -<<<<<<< HEAD -- [报告器 {#reporters}](#报告器-reporters) - - [onInit](#oninit) - - [onBrowserInit {#onbrowserinit}](#onbrowserinit-onbrowserinit) - - [onTestRunStart](#ontestrunstart) - - [onTestRunEnd](#ontestrunend) - - [onCoverage](#oncoverage) - - [onTestModuleQueued](#ontestmodulequeued) - - [onTestModuleCollected](#ontestmodulecollected) - - [onTestModuleStart](#ontestmodulestart) - - [onTestModuleEnd](#ontestmoduleend) - - [onHookStart](#onhookstart) - - [onHookEnd](#onhookend) - - [onTestSuiteReady](#ontestsuiteready) - - [onTestSuiteResult](#ontestsuiteresult) - - [onTestCaseReady](#ontestcaseready) - - [onTestCaseResult](#ontestcaseresult) - - [onTestAnnotate 3.2.0 {#ontestannotate}](#ontestannotate-320-ontestannotate) - - [onTestCaseArtifactRecord 4.0.11 {#ontestcaseartifactrecord}](#ontestcaseartifactrecord-4011-ontestcaseartifactrecord) -======= - [`onInit`](#oninit) - [`onTestRunStart`](#ontestrunstart) - [`onTestModuleQueued`](#ontestmodulequeued) @@ -48,9 +28,8 @@ Vitest 拥有自己的测试运行生命周期。这些生命周期通过报告 - [`onTestModuleEnd`](#ontestmoduleend) - [`onCoverage`](#oncoverage) - [`onTestRunEnd`](#ontestrunend) ->>>>>>> 4a2cb45c70fd529187caa33f464836923f2fd444 -除非被跳过,否则单个模块中的测试和 reporters 将按顺序报告。所有跳过的测试将在 reporters /模块的末尾报告。 +除非被跳过,否则单个模块中的测试和 reporters 将按顺序报告。所有跳过的测试将在 reporters 测试套件或模块的末尾报告。 请注意,由于测试模块可以并行运行,Vitest 将并行报告它们。 @@ -343,11 +322,7 @@ function onTestCaseAnnotate( ): Awaitable ``` -<<<<<<< HEAD -onTestAnnotate 是与 [`context.annotate`](/guide/test-context#annotate) 方法配套使用的钩子。当你在测试中调用 annotate 后, Vitest 会将注解内容序列化,并将其发送到主线程,从而让报告器可以处理这些附加信息。 -======= -The `onTestCaseAnnotate` hook is associated with the [`context.annotate`](/guide/test-context#annotate) method. When `annotate` is invoked, Vitest serialises it and sends the same attachment to the main thread where reporter can interact with it. ->>>>>>> 4a2cb45c70fd529187caa33f464836923f2fd444 +`onTestCaseAnnotate` 是与 [`context.annotate`](/guide/test-context#annotate) 方法配套使用的钩子。当你在测试中调用 annotate 后, Vitest 会将注解内容序列化,并将其发送到主线程,从而让报告器可以处理这些附加信息。 如果在注解中指定了文件路径, Vitest 会将附件保存到一个独立的目录(该目录通过 [`attachmentsDir`](/config/#attachmentsdir) 配置),并自动更新 path 属性,使其指向存储后的文件位置。 diff --git a/api/advanced/runner.md b/api/advanced/runner.md index cc1dca9a..f4432b06 100644 --- a/api/advanced/runner.md +++ b/api/advanced/runner.md @@ -42,13 +42,8 @@ export interface VitestRunner { */ onAfterTryTask?: (test: Test, options: { retry: number; repeats: number }) => unknown /** -<<<<<<< HEAD * 在重试结果确定后调用。与 `onAfterTryTask` 不同,此时测试已进入新的状态, * 并且所有的 `after` 钩子此时也已被执行。 -======= - * Called after the retry resolution happened. Unlike `onAfterTryTask`, the test now has a new state. - * All `after` hooks were also called by this point. ->>>>>>> 4a2cb45c70fd529187caa33f464836923f2fd444 */ onAfterRetryTask?: (test: Test, options: { retry: number; repeats: number }) => unknown diff --git a/api/advanced/vitest.md b/api/advanced/vitest.md index 969907b4..5daeb43c 100644 --- a/api/advanced/vitest.md +++ b/api/advanced/vitest.md @@ -480,13 +480,8 @@ function onCancel(fn: (reason: CancelReason) => Awaitable): () => void 注册一个处理程序,当测试运行被 [`vitest.cancelCurrentRun`](#cancelcurrentrun) 取消时调用。 -<<<<<<< HEAD -::: warning 实验性 -自 4.0.10 起,`onCancel` 会返回一个用于移除监听器的清理函数。 -::: -======= + Since 4.0.10, `onCancel` experimentally returns a teardown function that will remove the listener. Since 4.1.0 this behaviour is considered stable. ->>>>>>> 4a2cb45c70fd529187caa33f464836923f2fd444 ## onClose diff --git a/guide/advanced/tests.md b/guide/advanced/tests.md index 78cb06a8..1f6e2453 100644 --- a/guide/advanced/tests.md +++ b/guide/advanced/tests.md @@ -29,13 +29,6 @@ for (const testModule of testModules) { } ``` -<<<<<<< HEAD -::: tip -[`TestModule`](/api/advanced/test-module), [`TestSuite`](/api/advanced/test-suite) 和 [`TestCase`](/api/advanced/test-case) API 从 Vitest 2.1 开始不再是实验性的,并且遵循 SemVer。 -::: - -======= ->>>>>>> 4a2cb45c70fd529187caa33f464836923f2fd444 ## `createVitest` 创建一个 [Vitest](/api/advanced/vitest) 实例而不运行测试。 diff --git a/guide/environment.md b/guide/environment.md index cbaf98ed..b7e3eb23 100644 --- a/guide/environment.md +++ b/guide/environment.md @@ -49,11 +49,7 @@ import type { Environment } from 'vitest/runtime' export default { name: 'custom', viteEnvironment: 'ssr', -<<<<<<< HEAD - // 可选 - 仅在支持 "experimental-vm" 的情况下使用 -======= - // optional - only if you support "vmForks" or "vmThreads" pools ->>>>>>> 4a2cb45c70fd529187caa33f464836923f2fd444 + // 可选 - 仅在支持 "vmForks" 或 "vmThreads" 线程池时需要设置 async setupVM() { const vm = await import('node:vm') const context = vm.createContext() diff --git a/guide/parallelism.md b/guide/parallelism.md index f9c722ce..c4216b9d 100644 --- a/guide/parallelism.md +++ b/guide/parallelism.md @@ -12,11 +12,7 @@ outline: deep - `forks`(默认)和 `vmForks` 会在不同的 [child processes](https://nodejs.org/api/child_process.html) 中执行测试 - `threads` 和 `vmThreads` 则会在不同的 [worker threads](https://nodejs.org/api/worker_threads.html) 中运行 -<<<<<<< HEAD “子进程(child processes)” 和 “工作线程(worker threads)” 都统称为 “工作者(workers)”。你可以通过 [`maxWorkers`](/config/#maxworkers) 选项配置运行的工作者数量。 -======= -Both "child processes" and "worker threads" are referred to as "workers". You can configure the number of running workers with [`maxWorkers`](/config/#maxworkers) option. ->>>>>>> 4a2cb45c70fd529187caa33f464836923f2fd444 如果项目包含大量测试文件,通常并行执行会大幅提升速度。但具体效果还要看项目本身、运行环境以及是否启用了 [隔离](/config/#isolate)。若需要关闭文件级并行化,可以将 [`fileParallelism`](/config/#fileparallelism) 设为 `false` 。更多性能优化技巧,请参考 [性能指南](/guide/improving-performance) 。 diff --git a/guide/snapshot.md b/guide/snapshot.md index 34919910..99db52a4 100644 --- a/guide/snapshot.md +++ b/guide/snapshot.md @@ -98,11 +98,7 @@ it('render basic', async () => { ## 图像快照 {#visual-snapshots} -<<<<<<< HEAD -对于 UI 组件和页面的视觉回归测试,Vitest 通过[浏览器模式](/guide/browser/)提供了内置支持,使用 [`toMatchScreenshot()`](/api/browser/assertions#tomatchscreenshot-experimental) 断言: -======= -For visual regression testing of UI components and pages, Vitest provides built-in support through [browser mode](/guide/browser/) with the [`toMatchScreenshot()`](/api/browser/assertions#tomatchscreenshot) assertion: ->>>>>>> 4a2cb45c70fd529187caa33f464836923f2fd444 +对于 UI 组件和页面的视觉回归测试,Vitest 通过 [浏览器模式](/guide/browser/) 提供了内置支持,使用 [`toMatchScreenshot()`](/api/browser/assertions#tomatchscreenshot) 断言: ```ts import { expect, test } from 'vitest' @@ -114,7 +110,7 @@ test('button looks correct', async () => { }) ``` -它会捕获屏幕截图并与参考图像进行比较,以检测意外的视觉变化。在[视觉回归测试指南](/guide/browser/visual-regression-testing)中了解更多内容。 +它会捕获屏幕截图并与参考图像进行比较,以检测意外的视觉变化。在 [视觉回归测试指南](/guide/browser/visual-regression-testing)中了解更多内容。 ## 自定义序列化程序 {#custom-serializer}