Fresher~5 minNegative testingtoContainText.not matchers
Verify the locked-out user error
App: SwagShop, a practice e-commerce demo store (Saucedemo-style). Login: standard_user, locked_out_user, problem_user, performance_glitch_user / secret_sauce.
Interview scenario
"Negative tests matter as much as happy paths. Show me a test that proves a locked-out user cannot log in and sees the right message."
Acceptance criteria
- Log in as locked_out_user with password secret_sauce.
- Assert the error message says the user has been locked out.
- Assert the user is still on the login page (the URL does not contain /inventory).
tests/example.spec.tsPlaywright · TypeScript
Runs in your browser with a Playwright-compatible API: locators, auto-waiting actions, expect, imports between files and test.extend fixtures. Saved in this browser. Ctrl/⌘ + Enter runs.
Save your lab code to a GitHub repo in your name, automatically after every run.Sign in with GitHub
/sandbox/swagshopOpen ↗
Test output
Press Run tests to watch your code drive the practice app in the preview.
Reference solution
Try it yourself first. Then compare with the Playwright solution and the same test in Selenium Java with TestNG.