mirror of
https://github.com/microsoft/playwright-mcp.git
synced 2025-07-26 08:32:26 +08:00
Add test for browser_evaluate error handling (#719)
This commit is contained in:
parent
e3df209b96
commit
efe3ff0c7c
@ -49,3 +49,23 @@ test('browser_evaluate (element)', async ({ client, server }) => {
|
|||||||
},
|
},
|
||||||
})).toContainTextContent(`- Result: "red"`);
|
})).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/);
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user