Playwright / Quiz

Assertions That Refuse to Give Up

toHaveText vs toBe, the 5-second expect window, and why one await placement decides whether your assertion retries or flakes.

Difficulty
Easy
Format
Quiz
Points
100
Estimate
9 min

// MISSION BRIEF

Your Mission

Two assertions look identical in review. One retries until the UI settles. The other grabs a single snapshot mid-render and files a false alarm at 2 AM.

This quiz is about Playwright's web-first assertions: which ones retry, for how long, and how to assert on things the built-ins do not cover.

Speed bonus active.

// FIRST CONTACT

Battle teaser

What makes `await expect(locator).toHaveText('Done')` web-first?

  1. AIt only works on the first element of a page
  2. BIt re-checks the element repeatedly until the text matches or the expect timeout expires
  3. CIt runs before any other assertion in the file
  4. DIt checks the raw HTML source instead of the DOM
Answers, scoring, hints, and the full battle stay sealed.

// SKILL TAGS

playwrightassertionsexpectflakinesse2e-testing