Playwright · Middle · Question 26 of 75

When is expect.poll useful?

await expect.poll(async () => {
  const res = await request.get("/api/jobs/42");
  return (await res.json()).status;
}).toBe("done");
Show the answer

Correct answer: To retry a non-locator value until it matches

Explanation

Web-first assertions retry locator checks. expect.poll retries any async function, e.g. waiting for a background job.

Further reading

Problem with a question

Playwright · Middle · question 26

Test yourself

Take the Playwright · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz