I am using Playwright for API testing and to log request object in Playwright using the code below. I tried a few options but none of them worked. Can someone suggest how to do that? Thanks!
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'
}));
});
Try recording a HAR file:
Then view HAR online: http://www.softwareishard.com/har/viewer/
Or using custom reporter to log network report: https://github.com/cenfun/monocart-reporter?tab=readme-ov-file#attach-network-report