Skip to content

Commit 93797be

Browse files
authored
feat(browser): support custom kind in page.mark (#10302)
1 parent 1a64d60 commit 93797be

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
@@ -82,11 +82,11 @@ export const page: {
8282
/**
8383
* Add a trace marker when browser tracing is enabled.
8484
*/
85-
mark(name: string, options?: { stack?: string }): Promise<void>
85+
mark(name: string, options?: { stack?: string; kind?: BrowserTraceEntryKind }): Promise<void>
8686
/**
8787
* Group multiple operations under a trace marker when browser tracing is enabled.
8888
*/
89-
mark<T>(name: string, body: () => T | Promise<T>, options?: { stack?: string }): Promise<T>
89+
mark<T>(name: string, body: () => T | Promise<T>, options?: { stack?: string; kind?: BrowserTraceEntryKind }): Promise<T>
9090
/**
9191
* Extend default `page` object with custom methods.
9292
*/
@@ -127,18 +127,20 @@ The `path` is also ignored in that case.
127127
### mark
128128
129129
```ts
130-
function mark(name: string, options?: { stack?: string }): Promise<void>
130+
function mark(name: string, options?: { stack?: string; kind?: BrowserTraceEntryKind }): Promise<void>
131131
function mark<T>(
132132
name: string,
133133
body: () => T | Promise<T>,
134-
options?: { stack?: string },
134+
options?: { stack?: string; kind?: BrowserTraceEntryKind },
135135
): Promise<T>
136136
```
137137

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

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

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

144146
```ts
@@ -151,7 +153,7 @@ await page.mark('after submit')
151153
await page.mark('submit flow', async () => {
152154
await page.getByRole('textbox', { name: 'Email' }).fill('john@example.com')
153155
await page.getByRole('button', { name: 'Submit' }).click()
154-
})
156+
}, { kind: 'action' })
155157
```
156158

157159
::: tip

api/browser/locators.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,13 +846,15 @@ The `path` is also ignored in that case.
846846
### mark
847847

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

852852
Adds a named marker to the trace timeline and uses the current locator as marker context.
853853

854854
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.
855855

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

0 commit comments

Comments
 (0)