feat: add Playwright-compatible trace recorder (tauri mode)#5
Open
srsholmes wants to merge 2 commits into
Open
feat: add Playwright-compatible trace recorder (tauri mode)#5srsholmes wants to merge 2 commits into
srsholmes wants to merge 2 commits into
Conversation
Ports the TraceRecorder pattern from electrobun-playwright and wires it into createTauriTest() for tauri-mode tests. Each test now produces a Playwright-compatible trace.zip attached to the HTML report, viewable with `npx playwright show-trace`. - `packages/test/src/trace/recorder.ts` — writes NDJSON events + PNG frames (adapted from electrobun's bridge-side recorder; uses a captureFrame callback so the test client can source frames from the existing native_screenshot Rust command) - `packages/test/src/trace/writer.ts` — fflate zipSync writer (verbatim port; sync API works under Bun/Node without the WebWorker surprise) - `packages/test/src/trace/tracing-plugin-client.ts` — PluginClient subclass that intercepts every non-internal command with before/after native_screenshot calls, routes native_screenshot itself through super.send() to avoid recursion - Fixture starts/stops tracing around `await use()` and attaches the zip via testInfo.attach, mirroring electrobun's non-fatal error handling - Existing MP4 recording pipeline is untouched — trace is additive Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Emit `stepId` on every `before` event so the v8 trace viewer's test list panel renders correctly without relying on the v7→v8 modernizer fallback. - Detect `@playwright/test` version at runtime via `createRequire` so the trace header matches whatever version the user has installed, instead of a hardcoded "1.58.0" that goes stale on every bump. - Map `listWindows`/`waitForWindow` to `class: 'BrowserContext'` in trace events; everything else stays `Page`. The viewer renders this as "<class>.<method>" so context-shaped commands now read correctly. - Rename the `sha1` local in `captureFrame` to `resourceName` and add a comment clarifying that the field name is schema-mandated but we don't actually hash (so identical frames don't dedup). - Document show-trace compat in the class-level JSDoc: action list + per-action screenshots work, DOM/Network tabs will be empty for a Tauri webview. 136 unit tests pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports the
TraceRecorderpattern from electrobun-playwright and wires it intocreateTauriTest()for tauri-mode tests. Each test now produces atrace.zipattached to the Playwright HTML report, viewable with `npx playwright show-trace`.Architectural note
The electrobun version runs tracing in the Bun bridge (server-side). Tauri's runner is Rust, so this port puts the recorder on the JS test-client side and intercepts every non-internal command via a `PluginClient` subclass (`TracingPluginClient`). Frames come from the existing `native_screenshot` Rust command — no Rust-side changes.
Trade-off: one extra `native_screenshot` round-trip before and after each action command (~20-50ms on macOS via CoreGraphics). Acceptable — MP4 recording keeps running in parallel.
New files
Modified files
Test plan
Known non-blocking
`pnpm --filter @srsholmes/tauri-playwright typecheck` surfaces a pre-existing `ITEMS is not defined` error in `ipc-mock.test.ts:84` (present on `main` before this branch). Not touched by this PR.
🤖 Generated with Claude Code