Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(mcp): do not print console entries when --snapshot-mode=none set (#39378)
Pavel Feldman387ed589e8e1
diff --git a/packages/playwright/src/mcp/browser/response.ts b/packages/playwright/src/mcp/browser/response.tsindex 9ede782e3d..f28696436c 100644--- a/packages/playwright/src/mcp/browser/response.ts+++ b/packages/playwright/src/mcp/browser/response.ts@@ -215,7 +215,7 @@ export class Response {text.push(`- New console entries: ${tabSnapshot.consoleLink}`);if (tabSnapshot?.events.filter(event => event.type !== 'request').length) {for (const event of tabSnapshot.events) {- if (event.type === 'console' && this._context.config.outputMode !== 'file') {+ if (event.type === 'console' && this._context.config.outputMode !== 'file' && this._context.config.snapshot.mode !== 'none') {if (shouldIncludeMessage(this._context.config.console.level, event.message.type))text.push(`- ${trimMiddle(event.message.toString(), 100)}`);} else if (event.type === 'download-start') {diff --git a/tests/mcp/snapshot-mode.spec.ts b/tests/mcp/snapshot-mode.spec.tsindex d4467d3360..aca0481e68 100644--- a/tests/mcp/snapshot-mode.spec.ts+++ b/tests/mcp/snapshot-mode.spec.ts@@ -115,6 +115,32 @@ test('should respect --snapshot-mode=none', async ({ startClient, server }) => {});});+test('should not inline console messages with --snapshot-mode=none', async ({ startClient, server }) => {+ server.setContent('/', `+ <title>Tab one</title>+ <body>+ <button>Click me</button>+ <script>+ console.log('info message');+ console.error('error message');+ </script>+ </body>+ `, 'text/html');++ const { client } = await startClient({+ args: ['--snapshot-mode=none'],+ });++ const response = await client.callTool({+ name: 'browser_navigate',+ arguments: { url: server.PREFIX },+ });++ expect(response).not.toHaveResponse({+ events: expect.stringContaining('error message'),+ });+});+test('should respect snapshot[filename]', async ({ client, server }, testInfo) => {server.setContent('/', `<button>Button 1</button>`, 'text/html');