1
votes

My playwright test never passes when I use the command "page.waitForResponse". Although the API call is performed and can be seen in the network tab of chrome. I set the jest timeout to 30000, but this does not seem to be the issue.

it("Test", async () => {
  await page.goto("http://localhost:8080/")
 await Promise.all([
  await page.waitForResponse("https://development/my/call", {
    timeout: 1000,
  }),
  page.click("css=body")
])
})

Network

url: https://development/my/call
Status: 200
Type: xhr

Error

Async callback was not invoked within the 30000 ms timeout specified by jest.setTimeout.Error
1

1 Answers

1
votes

The problem might be in what you don't include in your question.

Typically, you have to start waiting for the response before the action that causes the call happens. Let's say that action is some click somewhere on the page, then you want to type:

await Promise.all([
    page.waitForResponse("http://localhost:8060/my/call"),
    page.click('.someButton'),
]);

Try this, it might be what will solve your problem.