Playwright / Scenario

Boss Fight: The Suite of a Thousand Sleeps

An inherited spec file with every sin in the book: shared login state, sleeps, positional XPath, one-shot assertions, and serial coupling. Plan the demolition.

Difficulty
Boss
Format
Scenario
Points
300
Estimate
20 min

// MISSION BRIEF

Your Mission

You inherited legacy-checkout.spec.ts, the most-hated file in the repo: 14 minutes of runtime, weekly false alarms, and a comment that says "DO NOT REORDER TESTS". Leadership has given you one sprint to civilize it.

This is the boss fight: identify every anti-pattern, sequence the rescue correctly, and dodge the tempting non-fixes. Decisions carry heavy weights, and partial credit is scarce.

// FIRST CONTACT

Battle teaser

First artifact

legacy-checkout.spec.ts (abridged, sins intact)

Roll call: which anti-patterns are actually present in this file? (Select all that apply.)

  1. AOrder-coupled tests smuggling state (savedCookies, serial mode, server-side cart)
  2. BOne-shot ElementHandle reads ($, textContent) instead of retrying web-first assertions
  3. CStructure-encoding positional XPath locators
  4. DFixed sleeps standing in for conditions (waitForTimeout x5)
Answers, scoring, hints, and the full battle stay sealed.

// SKILL TAGS

playwrightrefactoringanti-patternstest-architecturee2e-testing