我正在使用 Playwright 进行 API 测试,并使用下面的代码在 Playwright 中记录请求对象。我尝试了几种选择,但没有一个有效。有人可以建议如何做到这一点吗?谢谢!
test("create new stuff", async ({request}) => {
const newIssue = await request.post(`http://xyz/account/00000/test`, {
data: {
name: "test 123",
parentTagId: "60b2b3ce-fa32-4b65-8f71-83e9efc75638",
type: 1
}
});
// await console.log(request); // not working
// await console.log(request['data']); //not working
expect(request).toEqual(201);
expect(newIssue.status()).toEqual(201);
expect(newIssue.body()).toContainEqual(expect.objectContaining({
title: '[Bug] report 1',
body: 'Bug description'
}));
});
尝试录制 HAR 文件:
然后在线查看 HAR:http://www.softwareishard.com/har/viewer/
或使用自定义报告器记录网络报告:https://github.com/cenfun/monocart-reporter?tab=readme-ov-file#attach-network-report