Skip to content

Commit 72e981b

Browse files
committed
Merge branch 'sync-docs' of https://github.com/vitest-dev/docs-cn into sync-93797bed-1
2 parents 3530b69 + 93797be commit 72e981b

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

api/browser/context.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ export const page: {
8181
/**
8282
* Add a trace marker when browser tracing is enabled.
8383
*/
84-
mark(name: string, options?: { stack?: string }): Promise<void>
84+
mark(name: string, options?: { stack?: string; kind?: BrowserTraceEntryKind }): Promise<void>
8585
/**
8686
* Group multiple operations under a trace marker when browser tracing is enabled.
8787
*/
88-
mark<T>(name: string, body: () => T | Promise<T>, options?: { stack?: string }): Promise<T>
88+
mark<T>(name: string, body: () => T | Promise<T>, options?: { stack?: string; kind?: BrowserTraceEntryKind }): Promise<T>
8989
/**
9090
* Extend default `page` object with custom methods.
9191
*/
@@ -126,18 +126,20 @@ export const page: {
126126
### mark
127127
128128
```ts
129-
function mark(name: string, options?: { stack?: string }): Promise<void>
129+
function mark(name: string, options?: { stack?: string; kind?: BrowserTraceEntryKind }): Promise<void>
130130
function mark<T>(
131131
name: string,
132132
body: () => T | Promise<T>,
133-
options?: { stack?: string },
133+
options?: { stack?: string; kind?: BrowserTraceEntryKind },
134134
): Promise<T>
135135
```
136136

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

139139
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.
140140

141+
Pass `options.kind` to categorize your marker as specific type, for example as `'action'`.
142+
141143
If you pass a callback, Vitest creates a trace group with this name, runs the callback, and closes the group automatically.
142144

143145
```ts
@@ -150,7 +152,7 @@ await page.mark('after submit')
150152
await page.mark('submit flow', async () => {
151153
await page.getByRole('textbox', { name: 'Email' }).fill('john@example.com')
152154
await page.getByRole('button', { name: 'Submit' }).click()
153-
})
155+
}, { kind: 'action' })
154156
```
155157

156158
::: tip

api/browser/locators.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,13 +847,15 @@ const { path, base64 } = await button.screenshot({
847847
### mark
848848

849849
```ts
850-
function mark(name: string, options?: { stack?: string }): Promise<void>
850+
function mark(name: string, options?: { stack?: string; kind?: BrowserTraceEntryKind }): Promise<void>
851851
```
852852

853853
在追踪时间线上添加一个具名标记,并使用当前定位器作为标记上下文。
854854

855855
传入 `options.stack` 以覆盖追踪元数据中的调用位置。适用于二次封装库并且需要保留用户调用源码位置的场景。
856856

857+
Pass `options.kind` to categorize your marker as specific type, for example as `'action'`.
858+
857859
```ts
858860
import { page } from 'vitest/browser'
859861

0 commit comments

Comments
 (0)