{"id":48926,"library":"playwright-ws-trace","title":"playwright-ws-trace","description":"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.","status":"active","version":"1.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/kabaneridev/playwright-ws-trace","tags":["javascript","playwright","websocket","trace","tracing","debugging","testing","e2e","automation"],"install":[{"cmd":"npm install playwright-ws-trace","lang":"bash","label":"npm"},{"cmd":"yarn add playwright-ws-trace","lang":"bash","label":"yarn"},{"cmd":"pnpm add playwright-ws-trace","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: required for Playwright tracing API","package":"@playwright/test","optional":false}],"imports":[{"note":"This package self-patches on install; no explicit import needed. Just import Playwright normally.","wrong":"import { something } from 'playwright-ws-trace'","symbol":"playwright-ws-trace","correct":"import '@playwright/test'; import '@playwright/test'; // no direct import needed, auto-patches"},{"note":"Tracing functions remain on Playwright's test context. No additional API from this package.","wrong":"import { trace } from 'playwright-ws-trace'","symbol":"trace","correct":"import { test } from '@playwright/test'; // use context.tracing.start/stop as usual"},{"note":"Manual script execution possible with --force flag if auto-patch fails.","wrong":"node node_modules/playwright-ws-trace/scripts/postinstall.js","symbol":"postinstall","correct":"npm install playwright-ws-trace # postinstall runs automatically"}],"quickstart":{"code":"// playwright.config.ts\nimport { defineConfig } from '@playwright/test';\nexport default defineConfig({\n  use: {\n    trace: 'on', // or 'on-first-retry', etc.\n  },\n});\n\n// my-test.spec.ts\nimport { test, expect } from '@playwright/test';\nimport { Page } from 'playwright'; // type only, not needed if not TS\n\ntest('capture ws frames', async ({ page, context }) => {\n  await context.tracing.start({ snapshots: true, screenshots: true });\n  await page.goto('https://example-websocket-app.com');\n  // interact with page to trigger WebSocket messages\n  await context.tracing.stop({ path: 'trace.zip' });\n});\n\n// After test: npx playwright show-trace ./trace.zip\n// In trace viewer: Network tab -> WS filter\n// Click WebSocket connection to see frames with direction (sent/received), timestamps, payload.","lang":"typescript","description":"Shows how to enable tracing (trace: 'on'), start/stop, and view WebSocket frames in trace viewer."},"warnings":[{"fix":"Re-run: npm uninstall playwright-ws-trace && npm install playwright-ws-trace OR node node_modules/playwright-ws-trace/scripts/postinstall.js --force","message":"After updating Playwright, patches must be reapplied manually.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add 'playwright-ws-trace' to trustedDependencies in package.json, then bun install","message":"Bun does not run postinstall scripts by default; patches won't apply.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Check GitHub releases or consider pinning Playwright version","message":"Playwright 1.59.x or later may break compatibility; only tested up to 1.58.x.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Monitor Playwright changelog for native WebSocket tracing support","message":"The package patches Playwright on install; future Playwright versions might adopt native WebSocket tracing, making this obsolete.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.1.2':13 '1.40.0':53 '18':56 '38427':63 'add':17 'altern':57 'autom':72 'built':33 'built-in':32 'captur':36 'cdp':49 'debug':69 'dedic':24 'direct':43 'e2e':71 'filter':26 'frame':6,19,38 'full':37 'hook':50 'instal':47 'javascript':64 'microsoft':59 'month':15 'network':29 'node':55 'patch':44 'payload':39 'playwright':2,9,35,45,65 'playwright-ws-trac':1 'playwright/test':52 'pr':62 'record':20 'reject':61 'releas':16 'requir':51 'sent/received':21 'stabl':14 'tab':30 'test':70 'timestamp':41 'trace':4,7,10,67,68 'unlik':31 'version':12 'via':48 'viewer':11 'websocket':5,18,66 'ws':3,25","created_at":"2026-06-07T16:59:10.218638+00:00","updated_at":"2026-06-07T16:59:10.218638+00:00","problems":[{"fix":"Run: node node_modules/playwright-ws-trace/scripts/postinstall.js --force","cause":"Postinstall script did not run (common on Bun or if Playwright updated after initial install).","error":"PATHS NOT APPLIED - WebSocket frames not showing in trace viewer"},{"fix":"Ensure @playwright/test >=1.40.0 and reinstall playwright-ws-trace","cause":"Playwright version incompatible or patch not applied correctly.","error":"TypeError: Cannot read properties of undefined (reading 'webSocketFrameReceived')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/kabaneridev/playwright-ws-trace#readme","github":"https://github.com/kabaneridev/playwright-ws-trace","docs":null,"changelog":null,"pypi":null,"npm":"playwright-ws-trace","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}