How to write a maintainable first E2E test
언제 쓸까: You have a staging URL and a login flow; you want one solid test before scaling.
흐름
-
Describe the flowWrite a Playwright test for login at staging.example.com: email, password, expect dashboard heading. Use role-based locators only.✓ 복사됨→ Test using getByRole, getByLabel; no .class or xpath
-
Add auth reuse fixtureConvert the login into a reusable auth fixture so other tests skip logging in.✓ 복사됨→ storageState-based fixture + globalSetup
-
Ensure non-flakinessAudit the test for waitFor* anti-patterns; switch to web-first assertions.✓ 복사됨→ expect(locator).toBeVisible() rather than waitForSelector
결과: A robust first test plus a fixture the whole suite inherits.
함정
- Claude reaches for page.waitForTimeout — Tell skill explicitly: no arbitrary waits, use web-first assertions