Write tests that catch the login bugs
advanced Test design Challenge 16 of 22
The Acme sign-in page has a test suite that only checks the page loads. Three versions of the page have bugs planted in them. Write tests that would catch every one of them, while still passing on the working app.
The page has Email and Password fields and a Sign in button. Valid credentials are ada@example.com / correct-horse.
How the page should behave
- Sign in is disabled until both fields have a value.
- Valid credentials take you to
/shop, which shows “Signed in as ada@example.com”. - A wrong password shows an alert reading “Invalid email or password” and keeps you on
/login.
Requirements
- All your tests pass on the working app.
- Each buggy version makes at least one of your tests fail.
- Use the preview of the demo app to explore the page before you write locators.
Expected output
Every test passes on the working app, and each buggy version makes at least one test fail.
Scenarios (4)
Your tests run once against each version of the demo app. They must pass on the working app and fail on every version with a planted bug.
- ○Working app · must pass
- ○Bug: no error for a wrong password · must catch
- ○Bug: Sign in enabled while empty · must catch
- ○Bug: no redirect after sign-in · must catch
Ctrl/⌘ + Enter to run tests · your code is saved in this browser
Results
Run the tests to see results here.
Demo app
The working app. You can click around it; your tests start from a fresh copy.
Related interview questions
- Explain Browser, BrowserContext and Page in Playwright. Why do contexts matter for test isolation?
- How do Playwright fixtures work? Build a custom fixture with test.extend.
- How do you avoid logging in through the UI in every Playwright test?
- How do you mock or modify network responses in Playwright, and when should you?