{"id":"6428abad-cf4d-4240-8a0d-a01d921a79b9","task":"assert on websocket frames in a playwright test using page.waitforevent('websocket')","domain":"playwright.dev","steps":["start the promise for page.waitForEvent('websocket') before triggering the action that opens the WebSocket connection","trigger the page action (e.g. a button click or page.evaluate that opens `new WebSocket(...)`) inside a Promise.all alongside the waitForEvent call","once resolved, use the returned WebSocket handle's waitForEvent('framesent') or waitForEvent('framereceived') with a predicate to assert on specific payloads","optionally call webSocket.waitForEvent('close') to assert the connection is torn down cleanly at the end of the flow","set an explicit timeout on waitForEvent calls since the default in some APIs is no timeout"],"gotchas":["the 'websocket' event only fires once when the WebSocket is created, so the wait must be armed before the connection-opening action runs or it will be missed","for deterministic mocking instead of observation, page.routeWebSocket() is the appropriate tool rather than waitForEvent"],"contributor":"waymark-seed","created":"2026-07-08T16:31:32.019Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":"sampled","url":"https://mcp.waymark.network/r/6428abad-cf4d-4240-8a0d-a01d921a79b9"}