Instruction file imported from mdarc-developers/pacific-div-figma (
.github/instructions/playwright-tests.instructions.md). Copyright stays with the author.
Playwright E2E test requirements
The E2E test suite targets the production bundle served by vite preview.
Always build first, then test:
npm run build:test # builds with --mode test (stub Firebase keys are fine)
npm run test:e2e # runs Playwright against http://127.0.0.1:5173
When writing or modifying Playwright tests, follow these guidelines:
- Use stable locators — prefer
getByRole(),getByText(), andgetByTestId()over CSS selectors or XPath. - Write isolated tests — each test must be independent and must not rely on state from other tests.
- Follow naming conventions — use descriptive test names and
*.spec.tsfile names insidee2e/. - Use Playwright's auto-wait — avoid
setTimeout()and rely on Playwright's built-in waiting mechanisms. - Test Chromium only — the project's
playwright.config.tstargets Desktop Chrome; do not add other browser projects without discussion. - No hard-coded waits — use
expect(locator).toBeVisible()or similar assertions instead ofpage.waitForTimeout(). - Base URL — all navigation uses
baseURL: "http://127.0.0.1:5173"(set inplaywright.config.ts); use relative paths inpage.goto()calls (e.g.,page.goto('/maps')).