Chrome DevTools for coding agents
fix: add a message indicating that no console messages exist (#91)
Alex Rudenko1a4ba4d3e05f
diff --git a/src/McpResponse.ts b/src/McpResponse.tsindex 63a2e155..e1af6f9c 100644--- a/src/McpResponse.ts+++ b/src/McpResponse.ts@@ -172,7 +172,11 @@ Call browser_handle_dialog to handle it before continuing.`);if (this.#includeConsoleData && this.#formattedConsoleData) {response.push('## Console messages');- response.push(...this.#formattedConsoleData);+ if (this.#formattedConsoleData.length) {+ response.push(...this.#formattedConsoleData);+ } else {+ response.push('<no console messages found>');+ }}const text: TextContent = {diff --git a/tests/McpResponse.test.ts b/tests/McpResponse.test.tsindex e4fcdc6b..40f775f7 100644--- a/tests/McpResponse.test.ts+++ b/tests/McpResponse.test.ts@@ -246,4 +246,18 @@ Log>`),assert.ok(result[0].text.toString().includes('Hello from the test'));});});++ it('adds a message when no console messages exist', async () => {+ await withBrowser(async (response, context) => {+ response.setIncludeConsoleData(true);+ const result = await response.handle('test', context);+ assert.ok(result[0].text);+ assert.strictEqual(+ result[0].text.toString(),+ `# test response+## Console messages+<no console messages found>`,+ );+ });+ });});