My playwright test never passes when I use the mand "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
My playwright test never passes when I use the mand "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
Share
Improve this question
edited Jan 20, 2024 at 0:31
ggorlen
58k8 gold badges114 silver badges157 bronze badges
asked May 26, 2021 at 10:02
vuvuvuvu
5,34818 gold badges59 silver badges90 bronze badges
1
-
The golden rule for
Promise.all()
: virtually never should any of the array elements haveawait
in front of them--you want to pass the promises, not their resolved values, into thePromise.all
array. You want to await the result of all the promises, one time, which is theawait
in front ofPromise.all()
. – ggorlen Commented Jan 20, 2024 at 0:29
1 Answer
Reset to default 5The 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.