Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
23 changes: 23 additions & 0 deletions api/browser/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,30 @@ declare module 'vitest/browser' {
如果自定义命令具有相同的名称,则它们将覆盖内置命令。
:::

<<<<<<< HEAD
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove unresolved merge markers in commands doc

This file still contains Git conflict markers (<<<<<<<, =======, >>>>>>>), which means the merge was not resolved and both variants are published verbatim. In rendered docs this shows broken content structure and duplicate section intent, and in doc-processing pipelines it can also break tooling that assumes clean Markdown.

Useful? React with 👍 / 👎.

### 自定义 `playwright` 命令 {#custom-playwright-commands}
=======
### Recording trace markers

Custom commands can record [trace markers](/api/browser/context#mark) for the test that triggered them through `context.mark`. This is the server-side equivalent of `page.mark` and helps annotate the [trace view](/guide/browser/trace-view) with custom actions performed inside a command.

```ts
import type { BrowserCommand } from 'vitest/node'

export const uploadFixture: BrowserCommand<[name: string]> = async (
context,
name,
) => {
await context.mark(`upload start: ${name}`, { kind: 'action' })
// ... do server-side work
await context.mark(`upload done: ${name}`, { kind: 'action' })
}
```

`context.mark` is a no-op when browser tracing is not enabled or no test is currently running in the session. Unlike `page.mark`, it does not accept a callback form.

### Custom `playwright` commands
>>>>>>> ea5391c0ee318d8eb6cd0fc7ea237d854171fbc2

Vitest 在命令上下文中公开了几个`playwright`特定属性。

Expand Down
2 changes: 2 additions & 0 deletions api/browser/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ await page.mark('submit flow', async () => {

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

A server-side equivalent is available on the [`BrowserCommandContext`](/api/browser/commands#recording-trace-markers) so [custom commands](/api/browser/commands#custom-commands) can record markers attributed to the test that triggered them.
:::

### frameLocator
Expand Down
8 changes: 7 additions & 1 deletion config/attachmentsdir.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
outline: deep
---

# attachmentsDir
# attachmentsDir <CRoot />

- **类型:** `string`
- **默认值:** `'.vitest/attachments'`

<<<<<<< HEAD

Check failure on line 11 in config/attachmentsdir.md

View workflow job for this annotation

GitHub Actions / autofix

Unexpected additional H1 heading found
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove unresolved merge markers in attachmentsDir doc

The conflict marker block indicates an incomplete merge in this config page, so users will see raw conflict syntax and conflicting language variants instead of a single authoritative description. This is a correctness issue for published documentation and should be resolved before release.

Useful? React with 👍 / 👎.

用于存储 [`context.annotate`](/guide/test-context#annotate) 所创建附件的目录路径(相对于项目根目录)。
=======
Directory path for storing file attachments created by [`context.annotate`](/guide/test-context#annotate).

This option is resolved relative to the root Vitest config. When using [`projects`](/guide/projects), all projects share the same `attachmentsDir`; it cannot be configured per project.
>>>>>>> ea5391c0ee318d8eb6cd0fc7ea237d854171fbc2
2 changes: 1 addition & 1 deletion guide/browser/trace-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Trace entries are recorded automatically for:

Each entry captures the DOM state at that point, along with timing information, the selector, and the source location that triggered it.

Element highlighting is best-effort. Some provider-specific selectors, shadow DOM selectors, or elements that are not present in the captured snapshot may not be highlighted.
In Vitest UI, trace entries are streamed as the test runs, so you can inspect recorded steps before the test finishes. Long-running actions, `expect.element(...)` assertions, and callback `page.mark()` entries appear as in-progress steps first, then update with their final status and duration.

## Custom Trace Entries

Expand Down
8 changes: 8 additions & 0 deletions guide/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,18 @@ export default defineConfig({
::: danger 不支持的选项
部分配置选项不允许在项目配置中使用,主要包括:

<<<<<<< HEAD
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Resolve merge conflict block in projects guide

An unresolved conflict block remains in the “unsupported options” section, leaving two contradictory list variants in the source. This causes end-user documentation corruption and makes it unclear which options are actually unsupported in project-level config.

Useful? React with 👍 / 👎.

- `coverage`:覆盖率统计针对整个进程
- `reporters`:只支持根级别的 reporters
- `resolveSnapshotPath`:只尊重根级别的快照路径解析器
- 其他不影响测试运行器的选项
=======
- `coverage`: coverage is done for the whole process
- `reporters`: only root-level reporters can be supported
- `resolveSnapshotPath`: only root-level resolver is respected
- `attachmentsDir`: attachments are stored in one root-level directory shared by all projects
- all other options that don't affect test runners
>>>>>>> ea5391c0ee318d8eb6cd0fc7ea237d854171fbc2

所有不支持在项目配置中使用的配置选项,在 ["配置"](/config/) 指南中会用 <CRoot /> 标记。它们必须在根配置文件中定义一次。
:::
Loading