Skip to content

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

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

feat(browser): support dom snapshot trace view#10102
hi-ogawa wants to merge 111 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

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 UI same as above
# - 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
# - 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, font, etc.) (this is actually complex. documented as limitation for now and will create a follow-up issue)
    • window/viewport size, overflow scroll
  • 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
    • provideres
      • playwright
      • webdriverio (highlight broken)
      • preview (no idea)
    • e2e: test/ui (verifies trace view is actually visible)
    • e2e: test/browser (verifies trace artifacts recording)
    • unit: packages/ui (component level interaction)
    • test on real projects in the ecosystem https://gist.github.com/hi-ogawa/2f1d9686457186cc845f4b9194dd4a5f
      • vueuse: pnpm test:chromium --browser.traceView --ui
      • vuetify: pnpm -C packages/vuetify/ test:browser --browser.traceView --ui --watch --standalone
  • docs
    • basic
    • more options
    • known limitations
  • enhance trace
    • semantic color, status
    • timestamp
    • duration
    • rename __vitest_click -> vitest:click
  • review left out TODOs
  • review rrweb
  • 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 b822426
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69e19bb45f76c100070d3fd1
😎 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 and others added 28 commits April 15, 2026 10:09
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
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

2 participants