diff --git a/test/lib/browsers/playwright.ts b/test/lib/browsers/playwright.ts index a65d40ed66ec..cca74133c8a0 100644 --- a/test/lib/browsers/playwright.ts +++ b/test/lib/browsers/playwright.ts @@ -318,15 +318,17 @@ export class Playwright { } 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) => { @@ -337,7 +339,7 @@ export class Playwright { 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(() => {}) }