From 1b4986d1aa036a2cee2ff949ef3608895e839f56 Mon Sep 17 00:00:00 2001 From: "Bonaventure C. J. Ugwu" <73999585+BonaventureCJ@users.noreply.github.com> Date: Tue, 2 Jun 2026 08:19:13 +0100 Subject: [PATCH 1/6] docs: clarify placeholder usage (#10496) --- guide/learn/writing-tests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/learn/writing-tests.md b/guide/learn/writing-tests.md index a047001b..35be6bb3 100644 --- a/guide/learn/writing-tests.md +++ b/guide/learn/writing-tests.md @@ -176,7 +176,7 @@ test.for([ }) ``` -The placeholders `%i`, `%s`, and `%f` in the test name are replaced with the corresponding values from each row, so the output shows `add(1, 1) -> 2`, `add(1, 2) -> 3`, and so on. +In the example above, the %i placeholders are replaced with the integer values from each data row. Vitest also supports other placeholder types, such as %s for strings and %f for floating-point numbers. As a result, the test runner generates test names such as add(1, 1) -> 2, add(1, 2) -> 3, and add(2, 1) -> 3. If your cases have more than two or three values, passing objects is more readable. Use `$property` in the name to interpolate fields: From a405655a581196481bf6bae0a817f961cc7f0305 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 2 Jun 2026 23:42:50 +0900 Subject: [PATCH 2/6] fix!: don't lookup config file from ancestor directories (#10428) Co-authored-by: Codex Co-authored-by: Hiroshi Ogawa <4232207+hi-ogawa@users.noreply.github.com> --- config/index.md | 2 ++ guide/migration.md | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/config/index.md b/config/index.md index 3a477823..30a72215 100644 --- a/config/index.md +++ b/config/index.md @@ -10,6 +10,8 @@ If you are using Vite and have a `vite.config` file, Vitest will read it to matc - Pass `--config` option to CLI, e.g. `vitest --config ./path/to/vitest.config.ts` - Use `process.env.VITEST` or `mode` property on `defineConfig` (will be set to `test` if not overridden with `--mode`) to conditionally apply different configuration in `vite.config.ts`. Note that like any other environment variable, `VITEST` is also exposed on `import.meta.env` in your tests +When an explicit `--config` option is not provided, Vitest looks for `vitest.config.{ts,mts,cts,js,mjs,cjs}` first and `vite.config.{ts,mts,cts,js,mjs,cjs}` second in the project [`root`](/config/root). If no config file is found, Vitest will run without one. + To configure `vitest` itself, add `test` property in your Vite config. You'll also need to add a reference to Vitest types using a [triple slash command](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-types-) at the top of your config file, if you are importing `defineConfig` from `vite` itself. If you are not using `vite`, add `defineConfig` imported from `vitest/config` to your config file: diff --git a/guide/migration.md b/guide/migration.md index 4d8ebbe3..1bc18c24 100644 --- a/guide/migration.md +++ b/guide/migration.md @@ -125,6 +125,15 @@ await expect.element(banner).toMatchTextContent(/error/i) // [!code ++] await expect.element(banner).toHaveTextContent('Error!') ``` +### Config Files Are Not Looked Up From Parent Directories + +Vitest no longer searches parent directories for config files. If you previously relied on running `vitest` from a subdirectory while using a config file from a parent directory, pass the config explicitly and scope test discovery with `--dir`. For example, + +```bash +$ cd subdir && vitest # [!code --] +$ cd subdir && vitest --config ../vitest.config.ts # [!code ++] +``` + ## Migrating to Vitest 4.0 {#vitest-4} ::: warning Prerequisites From 78ee2995b40ef9f8e295c810946ab9b4e3690b6c Mon Sep 17 00:00:00 2001 From: Matt Bordas Date: Tue, 2 Jun 2026 11:44:04 -0400 Subject: [PATCH 3/6] docs(browser): re-word browser mode development status (#10509) --- guide/browser/why.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guide/browser/why.md b/guide/browser/why.md index 24e3d041..70ff8aab 100644 --- a/guide/browser/why.md +++ b/guide/browser/why.md @@ -23,9 +23,9 @@ To achieve the highest level of confidence in our tests, it's crucial to test in When using Vitest browser, it is important to consider the following drawbacks: -### Early Development +### Not a Drop-In Replacement -The browser mode feature of Vitest is still in its early stages of development. As such, it may not yet be fully optimized, and there may be some bugs or issues that have not yet been ironed out. It is recommended that users augment their Vitest browser experience with a standalone browser-side test runner like WebdriverIO, Cypress or Playwright. +The browser mode feature of Vitest does not completely replace standalone end-to-end test runners. It is recommended that users augment their Vitest browser experience with a standalone browser-side test runner like WebdriverIO, Cypress or Playwright. ### Longer Initialization From fa7b91791854e14250ed1f3538969313d26c7f08 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 3 Jun 2026 15:25:44 +0200 Subject: [PATCH 4/6] feat!: inline `@vitest/runner` package, do not publish it anymore (#10511) --- api/advanced/runner.md | 2 +- api/advanced/vitest.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/advanced/runner.md b/api/advanced/runner.md index fa41cbc8..1c514acb 100644 --- a/api/advanced/runner.md +++ b/api/advanced/runner.md @@ -95,7 +95,7 @@ export interface VitestRunner { /** * Publicly available configuration. */ - config: VitestRunnerConfig + config: SerializedConfig /** * The name of the current pool. Can affect how stack trace is inferred on the server side. */ diff --git a/api/advanced/vitest.md b/api/advanced/vitest.md index 8ae0e43d..5d2be646 100644 --- a/api/advanced/vitest.md +++ b/api/advanced/vitest.md @@ -27,7 +27,7 @@ This is a global [`ViteDevServer`](https://vite.dev/guide/api-javascript#vitedev Public `state` is an experimental API (except `vitest.state.getReportedEntity`). Breaking changes might not follow SemVer, please pin Vitest's version when using it. ::: -Global state stores information about the current tests. It uses the same API from `@vitest/runner` by default, but we recommend using the [Reported Tasks API](/api/advanced/reporters#reported-tasks) instead by calling `state.getReportedEntity()` on the `@vitest/runner` API: +Global state stores information about the current tests. It uses internal serializable Task API by default, but we recommend using the [Reported Tasks API](/api/advanced/reporters#reported-tasks) instead by calling `state.getReportedEntity()`: ```ts const task = vitest.state.idMap.get(taskId) // old API From e7f795332b12b19eadd410d67b6927bf6043762f Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Thu, 4 Jun 2026 16:10:23 +0900 Subject: [PATCH 5/6] fix!: allow mutating happy-dom/jsdom window object (#10373) Co-authored-by: Hiroshi Ogawa <4232207+hi-ogawa@users.noreply.github.com> Co-authored-by: Codex --- guide/migration.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/guide/migration.md b/guide/migration.md index 1bc18c24..ea3892bc 100644 --- a/guide/migration.md +++ b/guide/migration.md @@ -134,6 +134,10 @@ $ cd subdir && vitest # [!code --] $ cd subdir && vitest --config ../vitest.config.ts # [!code ++] ``` +### DOM Environment Global Assignments Now Update the Underlying Window + +Assignments to properties on `globalThis` or `window` in `jsdom` and `happy-dom` environments are now propagated to the underlying DOM implementation. Mutable properties such as `innerWidth` can affect APIs implemented by the DOM environment, for example `happy-dom`'s `matchMedia`. + ## Migrating to Vitest 4.0 {#vitest-4} ::: warning Prerequisites From 55cfbb7c33bf021a0ea437ffa3469bfb47b12a02 Mon Sep 17 00:00:00 2001 From: noise Date: Fri, 5 Jun 2026 09:58:51 +0800 Subject: [PATCH 6/6] docs(cn): dissolve the conflict --- api/advanced/vitest.md | 7 ++----- config/index.md | 8 ++------ guide/browser/why.md | 10 +++------- guide/learn/writing-tests.md | 6 +----- guide/migration.md | 6 +----- 5 files changed, 9 insertions(+), 28 deletions(-) diff --git a/api/advanced/vitest.md b/api/advanced/vitest.md index 225ca579..0749af20 100644 --- a/api/advanced/vitest.md +++ b/api/advanced/vitest.md @@ -27,11 +27,8 @@ Since Vitest 5, this property is always `'test'`. 公共 `state` 是一个实验性 API(除了 `vitest.state.getReportedEntity`)。破坏性更改可能不遵循 SemVer,请在使用时固定 Vitest 的版本。 ::: -<<<<<<< HEAD -全局状态存储有关当前测试的信息。默认情况下,它使用与 `@vitest/runner` 相同的 API,但我们建议通过调用 `@vitest/runner` API 上的 `state.getReportedEntity()` 来使用 [任务报告器 API](/api/advanced/reporters#reported-tasks): -======= -Global state stores information about the current tests. It uses internal serializable Task API by default, but we recommend using the [Reported Tasks API](/api/advanced/reporters#reported-tasks) instead by calling `state.getReportedEntity()`: ->>>>>>> e7f795332b12b19eadd410d67b6927bf6043762f + +全局状态存储有关当前测试的信息。默认情况下,它使用内部可序列化的任务 API,但我们建议通过调用 `state.getReportedEntity()` 来使用 [任务报告器 API](/api/advanced/reporters#reported-tasks): ```ts const task = vitest.state.idMap.get(taskId) // 旧 API diff --git a/config/index.md b/config/index.md index bb490fdc..5663a913 100644 --- a/config/index.md +++ b/config/index.md @@ -9,14 +9,10 @@ outline: deep - 创建 `vitest.config.ts`,它将具有更高的优先级,并且会**覆盖** `vite.config.ts` 中的配置(Vitest 支持所有传统的 JS 和 TS 文件扩展名,但不支持 `json`) - 这意味着我们在 `vite.config` 中的所有选项将被**忽略**。 - 向 CLI 传递 `--config` 选项,例如 `vitest --config ./path/to/vitest.config.ts`。 - 使用 `process.env.VITEST` 或在 `defineConfig` 上的 `mode` 属性(如果没有用 `--mode` 覆盖,默认设置为 `test`)也可以在 `vite.config.ts` 中有条件地应用不同的配置。请注意,像任何其他环境变量一样,`VITEST` 也会在测试中的 `import.meta.env` 上暴露出来。 - -<<<<<<< HEAD -要配置 Vitest 本身,请在我们的 Vite 配置中添加 `test` 属性。如果我们是从 `vite` 本身导入 `defineConfig`,我们还需要在配置文件顶部使用 [三斜杠指令](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-types-) 添加对 Vitest 类型引用。 -======= + When an explicit `--config` option is not provided, Vitest looks for `vitest.config.{ts,mts,cts,js,mjs,cjs}` first and `vite.config.{ts,mts,cts,js,mjs,cjs}` second in the project [`root`](/config/root). If no config file is found, Vitest will run without one. -To configure `vitest` itself, add `test` property in your Vite config. You'll also need to add a reference to Vitest types using a [triple slash command](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-types-) at the top of your config file, if you are importing `defineConfig` from `vite` itself. ->>>>>>> e7f795332b12b19eadd410d67b6927bf6043762f +要配置 Vitest 本身,请在我们的 Vite 配置中添加 `test` 属性。如果我们是从 `vite` 本身导入 `defineConfig`,我们还需要在配置文件顶部使用 [三斜杠指令](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-types-) 添加对 Vitest 类型引用。 如果你尚未使用 `vite` ,可以在配置文件中从 `vitest/config` 导入 `defineConfig`: diff --git a/guide/browser/why.md b/guide/browser/why.md index d1f0e40a..5f55db81 100644 --- a/guide/browser/why.md +++ b/guide/browser/why.md @@ -24,14 +24,10 @@ outline: deep ### 早期开发 {#early-development} -<<<<<<< HEAD -Vitest 的浏览器模式功能仍处于早期开发阶段。因此,它可能尚未完全优化,可能存在一些尚未解决的错误或问题。建议用户使用独立的浏览器端测试运行程序(如 WebdriverIO、Cypress 或 Playwright)来增强 Vitest 浏览器体验。 +### 非完全替代品 {#not-a-drop-in-replacement} -### 更长的初始化时间 {#longer-initialization} -======= -### Not a Drop-In Replacement +Vitest 的浏览器模式功能并不能完全替代独立的端到端测试运行器。建议用户使用独立的浏览器端测试运行程序(如 WebdriverIO、Cypress 或 Playwright)来增强 Vitest 浏览器体验。 -The browser mode feature of Vitest does not completely replace standalone end-to-end test runners. It is recommended that users augment their Vitest browser experience with a standalone browser-side test runner like WebdriverIO, Cypress or Playwright. ->>>>>>> e7f795332b12b19eadd410d67b6927bf6043762f +### 更长的初始化时间 {#longer-initialization} Vitest 浏览器在初始化过程中需要启动提供程序和浏览器,这可能需要一些时间。与其他测试模式相比,这可能导致更长的初始化时间。 diff --git a/guide/learn/writing-tests.md b/guide/learn/writing-tests.md index e9eb8002..a7e59acd 100644 --- a/guide/learn/writing-tests.md +++ b/guide/learn/writing-tests.md @@ -176,11 +176,7 @@ test.for([ }) ``` -<<<<<<< HEAD -测试名称中的占位符 `%i`、`%s` 和 `%f` 会被每行中对应的值替换,因此输出会显示 `add(1, 1) -> 2`、`add(1, 2) -> 3` 等。 -======= -In the example above, the %i placeholders are replaced with the integer values from each data row. Vitest also supports other placeholder types, such as %s for strings and %f for floating-point numbers. As a result, the test runner generates test names such as add(1, 1) -> 2, add(1, 2) -> 3, and add(2, 1) -> 3. ->>>>>>> e7f795332b12b19eadd410d67b6927bf6043762f +在上面的例子中,`%i` 占位符会被每个数据行中的整数值替换。Vitest 还支持其他类型的占位符,例如用于字符串的 `%s` 和用于浮点数的 `%f`。因此,测试运行器会生成诸如 `add(1, 1) -> 2`、`add(1, 2) -> 3` 和 `add(2, 1) -> 3` 这样的测试名称。 如果你的用例包含两个或三个以上的值,传递对象更具可读性。在名称中使用 `$property` 来插入字段: diff --git a/guide/migration.md b/guide/migration.md index 28db5ab9..54d8b71f 100644 --- a/guide/migration.md +++ b/guide/migration.md @@ -125,9 +125,6 @@ await expect.element(banner).toMatchTextContent(/error/i) // [!code ++] await expect.element(banner).toHaveTextContent('Error!') ``` -<<<<<<< HEAD -## 迁移至 Vitest 4.0 {#vitest-4} -======= ### Config Files Are Not Looked Up From Parent Directories Vitest no longer searches parent directories for config files. If you previously relied on running `vitest` from a subdirectory while using a config file from a parent directory, pass the config explicitly and scope test discovery with `--dir`. For example, @@ -141,8 +138,7 @@ $ cd subdir && vitest --config ../vitest.config.ts # [!code ++] Assignments to properties on `globalThis` or `window` in `jsdom` and `happy-dom` environments are now propagated to the underlying DOM implementation. Mutable properties such as `innerWidth` can affect APIs implemented by the DOM environment, for example `happy-dom`'s `matchMedia`. -## Migrating to Vitest 4.0 {#vitest-4} ->>>>>>> e7f795332b12b19eadd410d67b6927bf6043762f +## 迁移至 Vitest 4.0 {#vitest-4} ::: warning 前提条件 Vitest 4.0 要求 **Vite >= 6.0.0** 和 **Node.js >= 20.0.0**。