Playwright / Scenario
The Mock That Never Fired
The test stubs the quotes API with three fake quotes. The UI cheerfully renders twelve real ones. Find both holes in the interception.
- Difficulty
- Hard
- Format
- Scenario
- Points
- 200
- Estimate
- 15 min
// MISSION BRIEF
Your Mission
A pricing test mocks GET /api/quotes to return three canned quotes, then asserts the table. It passes... because the assertion is weak. The mock has never intercepted a single request, and today the live API changed and everything exploded.
Two separate defects hide in this interception setup. Find both, then decide how a mock proves it is actually engaged.
Decisions are weighted; the double diagnosis carries the day.
// FIRST CONTACT
Battle teaser
First artifact
quotes.spec.ts
Defect #1, the ordering problem:
- AThe handler must be async or it is skipped
- Bpage.route is registered AFTER page.goto, but the app fetches quotes during initial load, so the request departed before any handler existed
- CMocks only work on POST requests
- Droute.fulfill cannot return arrays
Answers, scoring, hints, and the full battle stay sealed.
// SKILL TAGS
playwrightnetwork-mockingdebuggingflakinesse2e-testing