Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 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
15daae2
docs(en): merging all conflicts
docschina-bot Mar 16, 2026
4435326
Merge branch 'dev' into backup-amend-15daae21
NoiseFan Mar 17, 2026
a8b063b
chore: release v4.1.0
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
1 change: 1 addition & 0 deletions .vitepress/scripts/cli-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const template = options.map((option) => {
const cli = option.cli
const [page, ...hash] = (title.startsWith('browser.') ? title.slice(8) : title).toLowerCase().split('.')
const config = skipConfig.has(title) ? '' : `[${title}](${title.includes('browser.') ? '/config/browser/' : '/config/'}${page}${hash.length ? `#${[page, ...hash].join('-')}` : ''})`
// eslint-disable-next-line e18e/prefer-static-regex
return `### ${title}\n\n- **CLI:** ${cli}\n${config ? `- **Config:** ${config}\n` : ''}\n${option.description.replace(/https:\/\/vitest\.dev\//g, '/')}\n`
}).join('\n')

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',
},
],
},
]
8 changes: 4 additions & 4 deletions api/advanced/metadata.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 任务元数据 <Badge type="danger">advanced</Badge>
# 任务元数据 <Badge type="danger">高级</Badge>

如果你正在开发自定义报告器或使用 Vitest Node.js API,你可能会发现将在各种上下文中执行的测试中的数据传递给报告器或自定义 Vitest 处理程序很有用。

Expand Down Expand Up @@ -33,12 +33,12 @@ export default {
} satisfies Reporter
```

::: danger BEWARE
::: danger 警告
Vitest 使用不同的方法与 Node.js 进程进行通信。

- 如果 Vitest 在工作线程内运行测试,它将通过[消息端口](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort)发送数据
- 如果 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) 包进行字符串化
- 如果 Vitest 在浏览器中运行测试,数据将使用 [flatted](https://npmx.dev/package/flatted) 包进行字符串化

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

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

Vitest 自 3.1 版起支持实验性的 `configureVitest` [插件](https://cn.vite.dev/guide/api-plugin) hook。
Vitest 自 3.1 版起支持 `configureVitest` [插件](https://cn.vite.dev/guide/api-plugin) hook。

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

::: info
如果 [根项目](/api/advanced/vitest#getroottestproject) 不是用户工作区的一部分,则不会解析其 `name`。
如果 [根项目](/api/advanced/vitest#getrootproject) 不是用户工作区的一部分,则不会解析其 `name`。
:::

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

## globalConfig

[`Vitest`](/api/advanced/vitest) 初始化时的测试配置。如果这是 [根项目](/api/advanced/vitest#getroottestproject),`globalConfig` 和 `config` 将引用同一个对象。此配置对于无法在项目级别设置的值非常有用,例如 `coverage` 或 `reporters`。
[`Vitest`](/api/advanced/vitest) 初始化时的测试配置。如果这是 [根项目](/api/advanced/vitest#getrootproject),`globalConfig` 和 `config` 将引用同一个对象。此配置对于无法在项目级别设置的值非常有用,例如 `coverage` 或 `reporters`。

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

检查当前项目是否为根项目。我们也可以通过调用 [`vitest.getRootProject()`](#getrootproject) 获取根项目。
检查当前项目是否为根项目。我们也可以通过调用 [`vitest.getRootProject()`](/api/advanced/vitest#getrootproject) 获取根项目。

## globTestFiles

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

::: tip
Vitest 使用 [fast-glob](https://www.npmjs.com/package/fast-glob) 来查找测试文件。`test.dir`、`test.root`、`root` 或 `process.cwd()` 定义了 `cwd` 选项。
Vitest 使用 [fast-glob](https://npmx.dev/package/fast-glob) 来查找测试文件。`test.dir`、`test.root`、`root` 或 `process.cwd()` 定义了 `cwd` 选项。

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

Expand Down
10 changes: 5 additions & 5 deletions api/browser/assertions.md
Original file line number Diff line number Diff line change
Expand Up @@ -1072,14 +1072,14 @@ await expect.element(getByTestId('button')).toMatchScreenshot('fancy-button', {
},
})
```

<!-- TODO: translation -->
### Options

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

用于比较图像的算法/库名称。
The algorithm/library used for comparing images.

目前,仅支持 [“pixelmatch”](https://github.com/mapbox/pixelmatch)。
`"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).

- `comparatorOptions: object`

Expand Down Expand Up @@ -1127,10 +1127,10 @@ await expect.element(getByTestId('button')).toMatchScreenshot('fancy-button', {
等待获取稳定截图的时间。

设为 `0` 可禁用超时,但如果无法确定稳定截图,进程将不会结束。

<!-- TODO: translation -->
#### `"pixelmatch"` comparator options

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

- `allowedMismatchedPixelRatio: number | undefined = undefined`

Expand Down
47 changes: 45 additions & 2 deletions api/browser/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const commands: BrowserCommands
:::

使用 [Commands API](/api/browser/commands) 如果您需要访问 Playwright 的 `page` 对象。
<!-- TODO: translation -->
```ts
export const page: {
/**
Expand All @@ -78,7 +79,15 @@ export const page: {
base64: string
}>) & ((options?: ScreenshotOptions) => Promise<string>)
/**
* 使用自定义方法扩展默认的 `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.
*/
extend: (methods: Partial<BrowserPage>) => BrowserPage
/**
Expand Down Expand Up @@ -114,6 +123,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 +289,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