Skip to content

feat(browser): add context.mark for custom command tracing - #10329

Merged
hi-ogawa merged 1 commit into
vitest-dev:mainfrom
AriPerkkio:feat/context-mark
May 12, 2026
Merged

hi-ogawa merged 1 commit into
vitest-dev:mainfrom
AriPerkkio:feat/context-mark

Conversation

@AriPerkkio

@AriPerkkio AriPerkkio commented May 12, 2026 •

Copy link
Copy Markdown
Member

Description

Adds context.mark for adding Trace View entries in custom commands:

import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    browser: {
      commands: {
        async example(context) {
          await context.mark("Custom marker from server!", { kind: "action" });
        },
      },
    },
  },
})
image image

Resolves #issue-number

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Drafted with Claude, finalized manually.

Comment on lines +30 to +35
let pageMarkHandler: ((name: string, options?: MarkOptions) => Promise<void>) | null = null

export function registerPageMarkHandler(handler: NonNullable<typeof pageMarkHandler>): void {
pageMarkHandler = handler
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Similar approach as onCancelCallbacks above.

Comment on lines +296 to +299
mark: async (name: string, options?: any) => {
const tester = (project.browser!.state as BrowserServerState).testers.get(rpcId)
await tester?.pageMark(name, options)
},

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We need to do round trip from server to browser, as client side has access to DOM where a snapshot is captured for the mark.

@netlify

netlify Bot commented May 12, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 31bbe66
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6a0373c4ae5f8c00086473ff
😎 Deploy Preview https://deploy-preview-10329--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@AriPerkkio
AriPerkkio force-pushed the feat/context-mark branch from 58c5a60 to 26a5e51 Compare May 12, 2026 13:56
@AriPerkkio
AriPerkkio marked this pull request as ready for review May 12, 2026 13:58
@AriPerkkio
AriPerkkio requested a review from hi-ogawa May 12, 2026 13:58
@AriPerkkio
AriPerkkio force-pushed the feat/context-mark branch from 26a5e51 to 31bbe66 Compare May 12, 2026 18:38
@hi-ogawa
hi-ogawa merged commit aa5140e into vitest-dev:main May 12, 2026
14 of 16 checks passed
@AriPerkkio
AriPerkkio deleted the feat/context-mark branch May 13, 2026 04:37
@github-actions github-actions Bot locked and limited conversation to collaborators May 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants