豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 6d0eb49

Browse files
authored
test: add a console error object test (#910)
1 parent b4a0888 commit 6d0eb49

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

tests/tools/console.test.js.snapshot

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,10 @@ Learn more:
112112
### Affected resources
113113
reqid=<reqid> data={"corsErrorStatus":{"corsError":"PreflightMissingAllowOriginHeader","failedParameter":""},"isWarning":false,"request":{"url":"http://hostname:port/data.json"},"initiatorOrigin":"","clientSecurityState":{"initiatorIsSecureContext":false,"initiatorIPAddressSpace":"Loopback","privateNetworkRequestPolicy":"BlockFromInsecureToMorePrivate"}}
114114
`;
115+
116+
exports[`console > list_console_messages > lists error objects 1`] = `
117+
# test response
118+
## Console messages
119+
Showing 1-1 of 1 (Page 1 of 1).
120+
msgid=1 [error] JSHandle@error (1 args)
121+
`;

tests/tools/console.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@ describe('console', () => {
4242
});
4343
});
4444

45+
it('lists error objects', async t => {
46+
await withMcpContext(async (response, context) => {
47+
const page = await context.newPage();
48+
await page.setContent(
49+
'<script>console.error(new Error("This is an error"))</script>',
50+
);
51+
await listConsoleMessages.handler({params: {}}, response, context);
52+
const formattedResponse = await response.handle('test', context);
53+
const textContent = getTextContent(formattedResponse.content[0]);
54+
t.assert.snapshot?.(textContent);
55+
});
56+
});
57+
4558
it('work with primitive unhandled errors', async () => {
4659
await withMcpContext(async (response, context) => {
4760
const page = await context.newPage();

0 commit comments

Comments
 (0)