Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions test/lib/browsers/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,17 @@ export class Playwright<TCurrent = undefined> {
}

page.on('websocket', (ws) => {
const decoder = tracePlaywright ? new TextDecoder() : null
if (tracePlaywright) {
page
.evaluate(`console.log('connected to ws at ${ws.url()}')`)
.catch(() => {})
// We're just evaluating a string here so that it appears in Playwright
// traces.
// console.log spams CI logs. If you already have a browser open, you can
// see WebSocket messages in the network tab of dev tools.
// TODO: Revisit once https://github.com/microsoft/playwright/issues/10996 is resolved.
page.evaluate(`'connected to ws at ${ws.url()}'`).catch(() => {})

ws.on('close', () =>
page
.evaluate(`console.log('closed websocket ${ws.url()}')`)
.catch(() => {})
page.evaluate(`'closed websocket ${ws.url()}'`).catch(() => {})
)
}
ws.on('framereceived', (frame) => {
Expand All @@ -337,7 +339,7 @@ export class Playwright<TCurrent = undefined> {
page
// Note that passing the payload as a an argument is 2 orders of magnitude more expensive in Playwright.
.evaluate(
`console.log('received ws message ${JSON.stringify(payload)}')`
`'received ws message ${JSON.stringify(typeof payload === 'string' ? payload : decoder!.decode(payload))}'`
)
.catch(() => {})
}
Expand Down
Loading