Skip to content

feat: add page/locator.mark API to enhance playwright trace#9652

Open
hi-ogawa wants to merge 47 commits intovitest-dev:mainfrom
hi-ogawa:02-13-feat_improve_playwright_trace
Open

feat: add page/locator.mark API to enhance playwright trace#9652
hi-ogawa wants to merge 47 commits intovitest-dev:mainfrom
hi-ogawa:02-13-feat_improve_playwright_trace

Conversation

@hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Feb 13, 2026

Description

Currently Vitest's playwright trace only logs playwright's action API (e.g. click). This PR adds "mark trace" command to add an arbitrary point in trace. This can be also used internally for expect.element, actions and render utility to show assertion location in source code.

The trace source from remote machine requires microsoft/playwright#39302 to be fixed, but this PR should give other improvements already, so I don't think we need to wait for that.

TODO

Example:

$ VITE_FAIL_TEST=1 pnpm -C examples/lit test --browser.trace=on --browser.headless --run
$ pnpm exec playwright show-trace examples/lit/test/__traces__/basic.test.ts/chromium-Button-with-increment-should-increment-the-count-on-each-click-0-0.trace.zip
🎥 trace view
Screencast.From.2026-02-20.10-00-45.mp4

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:.

@netlify
Copy link

netlify bot commented Feb 13, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 9bed8b3
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69991bd408f7d200080ab128
😎 Deploy Preview https://deploy-preview-9652--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@hi-ogawa hi-ogawa added the p2-to-be-discussed Enhancement under consideration (priority) label Feb 13, 2026
@hi-ogawa hi-ogawa moved this to P2 - 3 in Team Board Feb 13, 2026
@sheremet-va sheremet-va moved this from P2 - 3 to Approved in Team Board Feb 13, 2026
@sheremet-va sheremet-va added p2-nice-to-have Not breaking anything but nice to have (priority) and removed p2-to-be-discussed Enhancement under consideration (priority) labels Feb 13, 2026
@hi-ogawa hi-ogawa self-assigned this Feb 16, 2026
@hi-ogawa hi-ogawa changed the title feat: add markTrace command to improve playwright trace with source location feat: add markTrace API to enhance playwright trace Feb 17, 2026
Add @see links for page.mark and locator.mark to match surrounding browser context API documentation references.
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 19, 2026

@vitest/browser

npm i https://pkg.pr.new/@vitest/browser@9652

@vitest/browser-playwright

npm i https://pkg.pr.new/@vitest/browser-playwright@9652

@vitest/browser-preview

npm i https://pkg.pr.new/@vitest/browser-preview@9652

@vitest/browser-webdriverio

npm i https://pkg.pr.new/@vitest/browser-webdriverio@9652

@vitest/coverage-istanbul

npm i https://pkg.pr.new/@vitest/coverage-istanbul@9652

@vitest/coverage-v8

npm i https://pkg.pr.new/@vitest/coverage-v8@9652

@vitest/expect

npm i https://pkg.pr.new/@vitest/expect@9652

@vitest/mocker

npm i https://pkg.pr.new/@vitest/mocker@9652

@vitest/pretty-format

npm i https://pkg.pr.new/@vitest/pretty-format@9652

@vitest/runner

npm i https://pkg.pr.new/@vitest/runner@9652

@vitest/snapshot

npm i https://pkg.pr.new/@vitest/snapshot@9652

@vitest/spy

npm i https://pkg.pr.new/@vitest/spy@9652

@vitest/ui

npm i https://pkg.pr.new/@vitest/ui@9652

@vitest/utils

npm i https://pkg.pr.new/@vitest/utils@9652

vitest

npm i https://pkg.pr.new/vitest@9652

@vitest/web-worker

npm i https://pkg.pr.new/@vitest/web-worker@9652

@vitest/ws-client

npm i https://pkg.pr.new/@vitest/ws-client@9652

commit: 9bed8b3

Document how Playwright locator.describe works internally and why it complements but does not replace Vitest mark-based trace anchoring.
@hi-ogawa hi-ogawa marked this pull request as ready for review February 19, 2026 10:13
### mark

```ts
function mark(name: string, options?: { stack?: string }): Promise<void>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

stack? option is added so that vitest-browser-xxx render helper can manipulate the trace. see vitest-community/vitest-browser-react#47

@hi-ogawa hi-ogawa added this to the 4.1.0 milestone Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cr-tracked p2-nice-to-have Not breaking anything but nice to have (priority)

Projects

Status: Approved

Development

Successfully merging this pull request may close these issues.

2 participants