Add test for browser_evaluate error handling (#719)

This commit is contained in:
Copilot 2025-07-19 20:12:32 -07:00 committed by GitHub
parent e3df209b96
commit efe3ff0c7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -49,3 +49,23 @@ test('browser_evaluate (element)', async ({ client, server }) => {
},
})).toContainTextContent(`- Result: "red"`);
});
test('browser_evaluate (error)', async ({ client, server }) => {
expect(await client.callTool({
name: 'browser_navigate',
arguments: { url: server.HELLO_WORLD },
})).toContainTextContent(`- Page Title: Title`);
const result = await client.callTool({
name: 'browser_evaluate',
arguments: {
function: '() => nonExistentVariable',
},
});
expect(result.isError).toBe(true);
expect(result.content?.[0]?.text).toContain('nonExistentVariable');
// Check for common error patterns across browsers
const errorText = result.content?.[0]?.text || '';
expect(errorText).toMatch(/not defined|Can't find variable/);
});