Skip to content

feat(browser): support dom snapshot trace view#10102

Draft
hi-ogawa wants to merge 73 commits intovitest-dev:mainfrom
hi-ogawa:wip-builtin-trace-system
Draft

feat(browser): support dom snapshot trace view#10102
hi-ogawa wants to merge 73 commits intovitest-dev:mainfrom
hi-ogawa:wip-builtin-trace-system

Conversation

@hi-ogawa
Copy link
Copy Markdown
Collaborator

@hi-ogawa hi-ogawa commented Apr 8, 2026

Description

Quick demo

--browser.traceView option automatically enables watch UI or HTML reporter. This is to introduce new experience of browser mode as single opt-in flag as experimental feature. The goal is to make this mode as default and eventually retire "headed orchestrator UI" model (except "preview" provider?).

Docs https://deploy-preview-10102--vitest-dev.netlify.app/guide/browser/trace-view-v2

EDIT: I intiially had an opinionated config resolution:

  • --browser.traceView on watch mode to mean --browser.traceView --browser.headless --ui
  • --browser.traceView on run mode to mean --browser.traceView --reporter=html

But that's been reverted to allow users to specify each variant explicitly like below.

# watch ui
# - trace viewer shows up next to live view
pnpm -C examples/lit test --browser.traceView

# watch ui
# - this is not orchestrator UI, but "pure" UI mode with trace viewer
# - The orchestrator/tester runs in a separate headless browser
pnpm -C examples/lit test --browser.traceView --browser.headless --ui

# watch ui
# - trace viewer in "pure" UI mode
# - headed "live view" is in a separate headed browser driver window
pnpm -C examples/lit test --browser.traceView --browser.headless=false --browser.ui=false --ui

# html reporter
# - just a static UI mode but same content, so works almost identically with watch mode.
pnpm -C examples/lit test --browser.traceView --browser.headless --reporter=html
pnpm dlx serve examples/lit/html/
Screenshot
pnpm -C examples/lit test --browser.traceView --browser.headless --ui
image
pnpm -C examples/lit test --browser.traceView
image

TODO

  • snapshot + view prototype
    • snapshot + render
    • selector highlight
    • source location
    • external resources (css, images, etc.) (rrweb is supposed to cover all these reasonably)
    • window/viewport size
  • design viewer
    • step list
    • snapshot view
    • link to code view
    • link from code view (later. agents can one-shot it but I'm not ready to review)
    • open trace from artifact
  • option to differentiate playwright trace and builtin trace.
    • test.browser.traceView: true
    • the idea is to provide new experience around dome snapshot viewer as first-class citizen
    • imply --browser.headless --ui on watch
    • imply --browser.headless --reporter html on non watch
  • test
  • docs
  • review slop
  • design efficient trace format and persistence (later)

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
Copy Markdown

netlify bot commented Apr 8, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 186ec08
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69db42b2fb0dcc0008d9e05d
😎 Deploy Preview https://deploy-preview-10102--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 changed the title feat(browser): support trace viewer with dom snaphost feat(browser): support trace viewer with dom snapshot Apr 9, 2026
hi-ogawa and others added 9 commits April 9, 2026 15:54
… safe)

- store { serialized, nodeId } as snapshot payload in BrowserTraceEntry
- takeSnapshot() passes explicit Mirror to snapshot(), resolves ivya selector → nodeId
- TraceView.vue uses mirror.getNode(nodeId) after rebuild() instead of querySelector
- removes CSS selector approach which breaks for shadow DOM elements
- drops __vitest_css_from_element__ global (no longer needed)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- use getBoundingClientRect + position:fixed overlay div instead of inline styles
- snapshot DOM is untouched; overlay is purely visual
- use requestAnimationFrame to ensure layout before reading rect
- credit Playwright's highlight.ts as reference for the technique
- mirror.getNode(selectorId) for shadow DOM-safe element lookup

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- add __vitest_recordBrowserTrace server command (mirrors annotateTraces pattern)
  - resolves stack → location via parseStacktrace in one batch server-side
  - calls _testRun.recordArtifact directly, no browser-side recordArtifact
- BrowserTraceEntry gains location?: { file, line, column }
- TraceView shows clickable source location per step via openLocation composable

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hi-ogawa hi-ogawa changed the title feat(browser): support trace viewer with dom snapshot feat(browser): support dom snapshot trace view Apr 9, 2026
hi-ogawa and others added 3 commits April 10, 2026 09:46
Move browser traces out of the report card into the top panel layout and allow the trace viewer to open without browser orchestrator state.

Keep BrowserIframe visible during browser orchestration by splitting the top pane when a trace is active.

Co-authored-by: Codex <noreply@openai.com>
Wrap the trace viewer in a dedicated pane with a header and close action, and rename the component to TraceViewPane for consistency with the split layout.

Co-authored-by: Codex <noreply@openai.com>
@hi-ogawa hi-ogawa added the p2-to-be-discussed Enhancement under consideration (priority) label Apr 11, 2026
@hi-ogawa hi-ogawa moved this to P2 - 2 in Team Board Apr 11, 2026
hi-ogawa and others added 7 commits April 12, 2026 15:18
Document trace view as an additive browser debugging feature and list the explicit local, headless, and HTML reporter setups.

Co-authored-by: Codex <noreply@openai.com>
Keep trace view setup guidance focused on the main UI and reporter combinations.

Co-authored-by: Codex <noreply@openai.com>
Include the Vitest UI plus visible browser window workflow in the trace view setup table.

Co-authored-by: Codex <noreply@openai.com>
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 12, 2026

@vitest/browser

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

@vitest/browser-playwright

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

@vitest/browser-preview

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

@vitest/browser-webdriverio

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

@vitest/coverage-istanbul

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

@vitest/coverage-v8

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

@vitest/expect

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

@vitest/mocker

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

@vitest/pretty-format

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

@vitest/runner

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

@vitest/snapshot

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

@vitest/spy

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

@vitest/ui

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

@vitest/utils

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

vitest

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

@vitest/web-worker

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

@vitest/ws-client

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

commit: 273c1be

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cr-tracked p2-to-be-discussed Enhancement under consideration (priority)

Projects

Status: P2 - 2

Development

Successfully merging this pull request may close these issues.

Built-in trace viewer with DOM snapshots for browser mode

1 participant