Registry / testing / playwright-ws-trace

playwright-ws-trace

JSON →
library1.1.2jsnpmunverified

WebSocket frame tracing for Playwright trace viewer. Version 1.1.2 (stable, monthly releases). Adds WebSocket frame recording (sent/received) and a dedicated WS filter in the Network tab. Unlike built-in Playwright, captures full frame payloads with timestamps and direction. Patches Playwright on install via CDP hooks. Requires @playwright/test >=1.40.0 and Node >=18. Alternative to Microsoft's rejected PR #38427.

npm install playwright-ws-trace
INSTALL
IMPORT
SIG · PLAYWRIGHT-WS-TRAC
P
playwright-ws-trace
testingjavascriptv1.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

playwright-ws-trace
import '@playwright/test'; import '@playwright/test'; // no direct import needed, auto-patches
import { something } from 'playwright-ws-trace'
This package self-patches on install; no explicit import needed. Just import Playwright normally.
trace
import { test } from '@playwright/test'; // use context.tracing.start/stop as usual
import { trace } from 'playwright-ws-trace'
Tracing functions remain on Playwright's test context. No additional API from this package.
postinstall
npm install playwright-ws-trace # postinstall runs automatically
node node_modules/playwright-ws-trace/scripts/postinstall.js
Manual script execution possible with --force flag if auto-patch fails.

Shows how to enable tracing (trace: 'on'), start/stop, and view WebSocket frames in trace viewer.

// playwright.config.ts import { defineConfig } from '@playwright/test'; export default defineConfig({ use: { trace: 'on', // or 'on-first-retry', etc. }, }); // my-test.spec.ts import { test, expect } from '@playwright/test'; import { Page } from 'playwright'; // type only, not needed if not TS test('capture ws frames', async ({ page, context }) => { await context.tracing.start({ snapshots: true, screenshots: true }); await page.goto('https://example-websocket-app.com'); // interact with page to trigger WebSocket messages await context.tracing.stop({ path: 'trace.zip' }); }); // After test: npx playwright show-trace ./trace.zip // In trace viewer: Network tab -> WS filter // Click WebSocket connection to see frames with direction (sent/received), timestamps, payload.
Debug
Known issues
gotchaAfter updating Playwright, patches must be reapplied manually.
fix
Re-run: npm uninstall playwright-ws-trace && npm install playwright-ws-trace OR node node_modules/playwright-ws-trace/scripts/postinstall.js --force
affects: >=1.0.0
gotchaBun does not run postinstall scripts by default; patches won't apply.
fix
Add 'playwright-ws-trace' to trustedDependencies in package.json, then bun install
affects: >=1.0.0
breakingPlaywright 1.59.x or later may break compatibility; only tested up to 1.58.x.
fix
Check GitHub releases or consider pinning Playwright version
affects: >=1.0.0
deprecatedThe package patches Playwright on install; future Playwright versions might adopt native WebSocket tracing, making this obsolete.
fix
Monitor Playwright changelog for native WebSocket tracing support
affects: >=1.0.0
Errors
Common errors & fixes
PATHS NOT APPLIED - WebSocket frames not showing in trace viewer
Postinstall script did not run (common on Bun or if Playwright updated after initial install).
fix
Run: node node_modules/playwright-ws-trace/scripts/postinstall.js --force
TypeError: Cannot read properties of undefined (reading 'webSocketFrameReceived')
Playwright version incompatible or patch not applied correctly.
fix
Ensure @playwright/test >=1.40.0 and reinstall playwright-ws-trace
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies
@playwright/testrequiredpeer dependency: required for Playwright tracing API
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
playwright-ws-trace — npm install playwright-ws-trace · libregistry