10. Web-First Retrying Assertions & Auto-Waiting

Web-First Assertions

// Automatically retries until element is visible or timeout:
await expect(page.getByRole("button", { name: "Checkout" })).toBeVisible();
await expect(page.getByTestId("cart-badge")).toHaveText("3");
await expect(page).toHaveURL("https://targetqa.com/cart");

// Soft assertions (continue test execution on failure):
await expect.soft(page.getByTestId("banner")).toBeVisible();

Task

  • Implement buildAssertionStatus:
  • 1. Accept passed (boolean) and message (string).
  • 2. Return { status: passed ? "PASSED" : "FAILED", message }.
πŸ’‘Common doubts
Did you like the problem?
Lesson 10 of 18
JavaScript
Loading code editor…
Next