From d3c3640a5843d6fd252a37c969f6023e924b245d Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Mon, 26 Jan 2026 14:08:51 +0100 Subject: [PATCH] feat: stabilize experimental features --- docs/api/advanced/reporters.md | 8 ++++---- docs/api/advanced/test-module.md | 6 +++++- docs/api/advanced/test-specification.md | 2 +- docs/api/advanced/vitest.md | 4 +--- docs/api/browser/context.md | 1 - docs/guide/advanced/tests.md | 4 ---- docs/guide/environment.md | 2 +- docs/guide/snapshot.md | 2 +- packages/browser/context.d.ts | 1 - packages/browser/src/client/tester/context.ts | 3 --- packages/mocker/src/node/hoistMocks.ts | 1 - packages/vitest/src/node/test-specification.ts | 1 - packages/vitest/src/node/types/reporter.ts | 1 - 13 files changed, 13 insertions(+), 23 deletions(-) diff --git a/docs/api/advanced/reporters.md b/docs/api/advanced/reporters.md index 4e2b8e5a06e4..c4330e8fce66 100644 --- a/docs/api/advanced/reporters.md +++ b/docs/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/docs/api/advanced/test-module.md b/docs/api/advanced/test-module.md index 4b002e6003e8..15f15ad95c37 100644 --- a/docs/api/advanced/test-module.md +++ b/docs/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/docs/api/advanced/test-specification.md b/docs/api/advanced/test-specification.md index 7142bba96d78..f66a4aa0091d 100644 --- a/docs/api/advanced/test-specification.md +++ b/docs/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/docs/api/advanced/vitest.md b/docs/api/advanced/vitest.md index eafc027a1b1d..cdf94c580bff 100644 --- a/docs/api/advanced/vitest.md +++ b/docs/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/docs/api/browser/context.md b/docs/api/browser/context.md index c21120246236..c6cf0f8887ac 100644 --- a/docs/api/browser/context.md +++ b/docs/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/docs/guide/advanced/tests.md b/docs/guide/advanced/tests.md index 81d7b572dce6..a5c0e26f712b 100644 --- a/docs/guide/advanced/tests.md +++ b/docs/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/docs/guide/environment.md b/docs/guide/environment.md index eb7eaabde759..6c06964e4832 100644 --- a/docs/guide/environment.md +++ b/docs/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/docs/guide/snapshot.md b/docs/guide/snapshot.md index ea42a057e874..1d5860d77e1a 100644 --- a/docs/guide/snapshot.md +++ b/docs/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' diff --git a/packages/browser/context.d.ts b/packages/browser/context.d.ts index ef1c524e8462..308e0b75256e 100644 --- a/packages/browser/context.d.ts +++ b/packages/browser/context.d.ts @@ -866,7 +866,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/packages/browser/src/client/tester/context.ts b/packages/browser/src/client/tester/context.ts index 8229969ea444..349dfc890928 100644 --- a/packages/browser/src/client/tester/context.ts +++ b/packages/browser/src/client/tester/context.ts @@ -492,9 +492,6 @@ function getElementError(selector: string, container: Element): Error { return error } -/** - * @experimental - */ function configurePrettyDOM(options: StringifyOptions) { defaultOptions = options } diff --git a/packages/mocker/src/node/hoistMocks.ts b/packages/mocker/src/node/hoistMocks.ts index 4720d8d9f090..1ececc2e63b3 100644 --- a/packages/mocker/src/node/hoistMocks.ts +++ b/packages/mocker/src/node/hoistMocks.ts @@ -35,7 +35,6 @@ export interface HoistMocksOptions { * @default ["hoisted"] */ hoistedMethodNames?: string[] - // @experimental, TODO globalThisAccessor?: string regexpHoistable?: RegExp codeFrameGenerator?: CodeFrameGenerator diff --git a/packages/vitest/src/node/test-specification.ts b/packages/vitest/src/node/test-specification.ts index f3995fa55340..6ac1c9f7cadb 100644 --- a/packages/vitest/src/node/test-specification.ts +++ b/packages/vitest/src/node/test-specification.ts @@ -27,7 +27,6 @@ export class TestSpecification { public readonly moduleId: string /** * The current test pool. It's possible to have multiple pools in a single test project with `typecheck.enabled`. - * @experimental In later versions, the project will only support a single pool. */ public readonly pool: Pool /** diff --git a/packages/vitest/src/node/types/reporter.ts b/packages/vitest/src/node/types/reporter.ts index f3c283a22bf5..cb43e475c97e 100644 --- a/packages/vitest/src/node/types/reporter.ts +++ b/packages/vitest/src/node/types/reporter.ts @@ -13,7 +13,6 @@ export interface Reporter { /** * Called when the project initiated the browser instance. * project.browser will always be defined. - * @experimental */ onBrowserInit?: (project: TestProject) => Awaitable /** @internal */