Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
79904f2
feat(browser): use BlazeDiff instead of pixelmatch (#9514)
macarie Feb 19, 2026
7d55fc0
docs: add warning for clearMocks option in async tests (#9697)
sapphi-red Feb 20, 2026
c9d4769
feat(browser): add `findElement` and enable strict mode in webdriveri…
sheremet-va Feb 20, 2026
d814578
feat: support `update: "none"` and add docs about snapshots behavior …
hi-ogawa Feb 20, 2026
2b8f37b
feat: support playwright `launchOptions` with `connectOptions` (#9702)
hi-ogawa Feb 20, 2026
ad261f6
chore(deps): update all non-major dependencies (#9614)
renovate[bot] Feb 20, 2026
e2eead0
docs: add Aerius Ventilation to sponsors
sheremet-va Feb 21, 2026
3b205f5
chore(deps): update all non-major dependencies (#9719)
renovate[bot] Feb 24, 2026
95e0297
docs: add Vite and Node.js prerequisites to Vitest 4 migration guide …
andrewdamelio Feb 24, 2026
12569f2
docs: add links to older migration guides (#9733)
sheremet-va Feb 25, 2026
19adec1
docs: update vitest browser qwik link to official qwik organization (…
thejackshelton Feb 25, 2026
dd1437e
docs: fix `setTimerTickMode` example (#9746)
yjaaidi Feb 26, 2026
00fe3fa
fix: cancelling should stop current test immediately (#9729)
AriPerkkio Feb 26, 2026
9df076d
docs: add experimental options to performance guides (#9743)
sheremet-va Feb 26, 2026
4eeb91e
docs(sponsors): update special and platinum (#9750)
AriPerkkio Feb 27, 2026
6a8ff8e
docs(reporters): correct gitHub-actions reporter documentation (#9756)
literalpie Mar 1, 2026
795ecfb
docs: fix duplicated word in browser assertions docs (#9759)
Rohan5commit Mar 2, 2026
712423c
chore(deps): update all non-major dependencies (#9765)
renovate[bot] Mar 2, 2026
28da25a
feat(vitest): add run summary in GitHub Actions Reporter (#9579)
macarie Mar 3, 2026
95f13e7
feat: add `page/locator.mark` API to enhance playwright trace (#9652)
hi-ogawa Mar 3, 2026
0f77210
refator: update links to npmx (#9783)
sheremet-va Mar 4, 2026
bb54912
docs: fix typo in Intro.vue (#9784)
Potherca Mar 4, 2026
9572e14
chore(deps): update eslint packages (#9615)
renovate[bot] Mar 4, 2026
630bac9
fix: allow hyphens in project config file name pattern (#9760)
Koutaro-Hanabusa Mar 5, 2026
dd1975b
docs: add trace viewer screenshot to trace-view guide (#9791)
hi-ogawa Mar 5, 2026
4a9f6b6
docs: add link to discussion (#9809)
sheremet-va Mar 6, 2026
404aa86
docs: fix API config typo (#9815)
Rohan5commit Mar 7, 2026
81e9d1b
chore: correct 'overriden' → 'overridden' typos in docs and tests (#9…
mitre88 Mar 7, 2026
7a44bc6
docs: fix test tags typo (#9820)
Rohan5commit Mar 8, 2026
649c7f5
feat(reporters): add `agent` reporter to reduce ai agent token usage …
cpojer Mar 9, 2026
01e6d3b
chore(deps): update all non-major dependencies (#9824)
renovate[bot] Mar 9, 2026
de999c9
docs: fix configureVitest hook typo (#9829)
Rohan5commit Mar 9, 2026
10af37e
docs: trace mark integration with vitest-browser-react/vue/svelte (#9…
hi-ogawa Mar 10, 2026
d39708a
chore: update voidzero theme (#9850)
sheremet-va Mar 12, 2026
4067e3a
chore: add blog post for Vitest 4.1 (#9775)
sheremet-va Mar 12, 2026
9854d4d
docs: more consistent em-dashes in the blog post (#9853)
sheremet-va Mar 12, 2026
b72fc6b
docs: add vite+ alpha announcement banner (#9837)
mdong1909 Mar 13, 2026
2b55a25
docs(en): merging all conflicts
docschina-bot Mar 16, 2026
bb9b6bd
Merge branch 'dev' into sync-b72fc6b4-1
NoiseFan Mar 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ export default ({ mode }: { mode: string }) => {
},
},

banner: {
id: 'viteplus-alpha',
text: 'Announcing Vite+ Alpha: Open source. Unified. Next-gen.',
url: 'https://voidzero.dev/posts/announcing-vite-plus-alpha?utm_source=vitest&utm_content=top_banner',
},

carbonAds: {
code: 'CW7DVKJE',
placement: 'vitestdev',
Expand Down
24 changes: 15 additions & 9 deletions .vitepress/sponsors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ export const sponsors: SponsorTier[] = [
size: 'big',
items: [
{
name: 'NuxtLabs',
url: 'https://nuxtlabs.com',
img: '/nuxtlabs.svg',
name: 'Vercel',
url: 'https://vercel.com',
img: '/vercel.svg',
},
{
name: 'Bolt',
url: 'https://bolt.new',
img: '/bolt.svg',
name: 'Chromatic',
url: 'https://www.chromatic.com/?utm_source=vitest&utm_medium=sponsorship&utm_campaign=vitestSponsorship',
img: '/chromatic.svg',
},
{
name: 'Zammad',
Expand All @@ -26,10 +26,11 @@ export const sponsors: SponsorTier[] = [
tier: '铂金赞助商',
size: 'big',
items: [

{
name: 'Chromatic',
url: 'https://www.chromatic.com/?utm_source=vitest&utm_medium=sponsorship&utm_campaign=vitestSponsorship',
img: '/chromatic.svg',
name: 'Bolt',
url: 'https://bolt.new',
img: '/bolt.svg',
},
],
},
Expand Down Expand Up @@ -57,6 +58,11 @@ export const sponsors: SponsorTier[] = [
url: 'https://www.liminity.se/',
img: '/liminity.svg',
},
{
name: 'Aerius Ventilation',
url: 'https://aerius.se/',
img: '/aerius.png',
},
],
},
]
5 changes: 5 additions & 0 deletions .vitepress/theme/Intro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
应用测试变得轻而易举。Vitest 基于 Vite 构建,原生支持 Vite 配置,并复用相同的解析和转换。
</p>
<p class="text-pretty">
<<<<<<< HEAD
即使不使用 Vite,也同样可以使用 Vitest。它兼容 Jest,也同样适用于后端代码。
=======
You can also use Vitest even if you are not using Vite. It is Jest-compatible
and works for backend code too.
>>>>>>> b72fc6b467384d82f530164b077760e0919f8532
</p>
<a href="/guide/why" target="_blank" class="button w-fit mt-8 block lg:hidden">了解更多</a>
</div>
Expand Down
6 changes: 6 additions & 0 deletions api/advanced/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@ export default {
::: danger BEWARE
Vitest 使用不同的方法与 Node.js 进程进行通信。

<<<<<<< HEAD
- 如果 Vitest 在工作线程内运行测试,它将通过[消息端口](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort)发送数据
- 如果 Vitest 使用子进程,数据将通过 [`process.send`](https://nodejs.org/api/process.html#processsendmessage-sendhandle-options-callback) API 作为序列化缓冲区发送
- 如果 Vitest 在浏览器中运行测试,数据将使用 [flatted](https://www.npmjs.com/package/flatted) 包进行字符串化
=======
- If Vitest runs tests inside worker threads, it will send data via [message port](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort)
- If Vitest uses child process, the data will be send as a serialized Buffer via [`process.send`](https://nodejs.org/api/process.html#processsendmessage-sendhandle-options-callback) API
- If Vitest runs tests in the browser, the data will be stringified using [flatted](https://npmx.dev/package/flatted) package
>>>>>>> b72fc6b467384d82f530164b077760e0919f8532

该属性也会出现在每个测试的 `json` 报告中,因此请确保数据可以序列化为 JSON。

Expand Down
4 changes: 4 additions & 0 deletions api/advanced/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ outline: deep
本指南假设我们知道如何使用 [Vite 插件](https://vite.dev/guide/api-plugin.html)。
:::

<<<<<<< HEAD
Vitest 自 3.1 版起支持实验性的 `configureVitest` [插件](https://cn.vite.dev/guide/api-plugin) hook。
=======
Vitest supports a `configureVitest` [plugin](https://vite.dev/guide/api-plugin.html) hook since version 3.1.
>>>>>>> b72fc6b467384d82f530164b077760e0919f8532

::: code-group
```ts [only vitest]
Expand Down
16 changes: 16 additions & 0 deletions api/advanced/test-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ export default defineConfig({
:::

::: info
<<<<<<< HEAD
如果 [根项目](/api/advanced/vitest#getroottestproject) 不是用户工作区的一部分,则不会解析其 `name`。
=======
If the [root project](/api/advanced/vitest#getrootproject) is not part of user projects, its `name` will not be resolved.
>>>>>>> b72fc6b467384d82f530164b077760e0919f8532
:::

## vitest
Expand All @@ -78,7 +82,11 @@ project.serializedConfig === project.serializedConfig // ❌

## globalConfig

<<<<<<< HEAD
[`Vitest`](/api/advanced/vitest) 初始化时的测试配置。如果这是 [根项目](/api/advanced/vitest#getroottestproject),`globalConfig` 和 `config` 将引用同一个对象。此配置对于无法在项目级别设置的值非常有用,例如 `coverage` 或 `reporters`。
=======
The test config that [`Vitest`](/api/advanced/vitest) was initialized with. If this is the [root project](/api/advanced/vitest#getrootproject), `globalConfig` and `config` will reference the same object. This config is useful for values that cannot be set on the project level, like `coverage` or `reporters`.
>>>>>>> b72fc6b467384d82f530164b077760e0919f8532

```ts
import type { ResolvedConfig } from 'vitest/node'
Expand Down Expand Up @@ -206,7 +214,11 @@ await vitest.runTestSpecifications([specification])
function isRootProject(): boolean
```

<<<<<<< HEAD
检查当前项目是否为根项目。我们也可以通过调用 [`vitest.getRootProject()`](#getrootproject) 获取根项目。
=======
Checks if the current project is the root project. You can also get the root project by calling [`vitest.getRootProject()`](/api/advanced/vitest#getrootproject).
>>>>>>> b72fc6b467384d82f530164b077760e0919f8532

## globTestFiles

Expand All @@ -233,7 +245,11 @@ project.globTestFiles(['basic/foo.js:10']) // ❌
```

::: tip
<<<<<<< HEAD
Vitest 使用 [fast-glob](https://www.npmjs.com/package/fast-glob) 来查找测试文件。`test.dir`、`test.root`、`root` 或 `process.cwd()` 定义了 `cwd` 选项。
=======
Vitest uses [fast-glob](https://npmx.dev/package/fast-glob) to find test files. `test.dir`, `test.root`, `root` or `process.cwd()` define the `cwd` option.
>>>>>>> b72fc6b467384d82f530164b077760e0919f8532

此方法查看多个配置选项:

Expand Down
4 changes: 4 additions & 0 deletions api/advanced/vitest.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,11 @@ function collectTests(
function cancelCurrentRun(reason: CancelReason): Promise<void>
```

<<<<<<< HEAD
此方法将优雅地取消所有正在进行的测试。它将等待已启动的测试完成运行,并且不会运行已计划运行但尚未启动的测试。
=======
This method will gracefully cancel all ongoing tests. It will stop the on-going tests and will not run tests that were scheduled to run but haven't started yet.
>>>>>>> b72fc6b467384d82f530164b077760e0919f8532

## setGlobalTestNamePattern

Expand Down
14 changes: 14 additions & 0 deletions api/browser/assertions.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,11 @@ await expect.element(getByTestId('parent')).toContainHTML('</span>')
::: warning
你可能不需要使用这个匹配器。我们鼓励从用户在浏览器中感知应用程序的角度进行测试。这就是为什么不建议针对特定的 DOM 结构进行测试。

<<<<<<< HEAD
在某些情况下,被测试的代码会渲染从外部来源获取的 HTML,而你希望验证该 HTML 代码是否按预期使用。
=======
It could be useful in situations where the code being tested renders html that was obtained from an external source, and you want to validate that html code was used as intended.
>>>>>>> b72fc6b467384d82f530164b077760e0919f8532

不应使用它来检查你控制的 DOM 结构。请改用 [`toContainElement`](#tocontainelement)。
:::
Expand Down Expand Up @@ -1077,9 +1081,15 @@ await expect.element(getByTestId('button')).toMatchScreenshot('fancy-button', {

- `comparatorName: "pixelmatch" = "pixelmatch"`

<<<<<<< HEAD
用于比较图像的算法/库名称。

目前,仅支持 [“pixelmatch”](https://github.com/mapbox/pixelmatch)。
=======
The algorithm/library used for comparing images.

`"pixelmatch"` is the only built-in comparator, but you can use custom ones by [registering them in the config file](/config/browser/expect#browser-expect-tomatchscreenshot-comparators).
>>>>>>> b72fc6b467384d82f530164b077760e0919f8532

- `comparatorOptions: object`

Expand Down Expand Up @@ -1130,7 +1140,11 @@ await expect.element(getByTestId('button')).toMatchScreenshot('fancy-button', {

#### `"pixelmatch"` comparator options

<<<<<<< HEAD
使用 `"pixelmatch"` 比较器时,以下选项可用:
=======
The `"pixelmatch"` comparator uses [`@blazediff/core`](https://blazediff.dev/docs/core) under the hood. The following options are available when using it:
>>>>>>> b72fc6b467384d82f530164b077760e0919f8532

- `allowedMismatchedPixelRatio: number | undefined = undefined`

Expand Down
48 changes: 47 additions & 1 deletion api/browser/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,19 @@ export const page: {
base64: string
}>) & ((options?: ScreenshotOptions) => Promise<string>)
/**
<<<<<<< HEAD
* 使用自定义方法扩展默认的 `page` 对象。
=======
* Add a trace marker when browser tracing is enabled.
*/
mark(name: string, options?: { stack?: string }): Promise<void>
/**
* Group multiple operations under a trace marker when browser tracing is enabled.
*/
mark<T>(name: string, body: () => T | Promise<T>, options?: { stack?: string }): Promise<T>
/**
* Extend default `page` object with custom methods.
>>>>>>> b72fc6b467384d82f530164b077760e0919f8532
*/
extend: (methods: Partial<BrowserPage>) => BrowserPage
/**
Expand Down Expand Up @@ -114,6 +126,40 @@ export const page: {
在这种情况下,`path` 也会被忽略。
:::

### mark

```ts
function mark(name: string, options?: { stack?: string }): Promise<void>
function mark<T>(
name: string,
body: () => T | Promise<T>,
options?: { stack?: string },
): Promise<T>
```

Adds a named marker to the trace timeline for the current test.

Pass `options.stack` to override the callsite location in trace metadata. This is useful for wrapper libraries that need to preserve the end-user source location.

If you pass a callback, Vitest creates a trace group with this name, runs the callback, and closes the group automatically.

```ts
import { page } from 'vitest/browser'

await page.mark('before submit')
await page.getByRole('button', { name: 'Submit' }).click()
await page.mark('after submit')

await page.mark('submit flow', async () => {
await page.getByRole('textbox', { name: 'Email' }).fill('john@example.com')
await page.getByRole('button', { name: 'Submit' }).click()
})
```

::: tip
This method is useful only when [`browser.trace`](/config/browser/trace) is enabled.
:::

### frameLocator

```ts
Expand Down Expand Up @@ -246,7 +292,7 @@ utils.configurePrettyDOM({
- **`maxLength`** - Maximum length of the output string (default: `7000`)
- **`filterNode`** - A CSS selector string or function to filter out nodes from the output. When a string is provided, elements matching the selector will be excluded. When a function is provided, it should return `false` to exclude a node.
- **`highlight`** - Enable syntax highlighting (default: `true`)
- And other options from [`pretty-format`](https://www.npmjs.com/package/@vitest/pretty-format)
- And other options from [`pretty-format`](https://npmx.dev/package/@vitest/pretty-format)

#### Filtering with CSS Selectors <Version>4.1.0</Version> {#filtering-with-css-selectors}

Expand Down
Loading
Loading