如何在剧作家 API 测试中记录请求对象

问题描述 投票:0回答:1

我正在使用 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'
  }));
});
javascript automated-tests playwright playwright-test
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.