Playwright Test Authoring
Quick Start
- •Identify whether the request is UI, API, or both.
- •Read
references/repo-patterns.mdfor file locations and conventions. - •Use
references/templates.mdas a starting point for new specs, page objects, or components.
Workflow
- •Locate or create the target spec in
tests/(UI) ortests-api/(API). - •Reuse existing page objects/components; add new ones only when needed.
- •Implement tests with
test.describe,test.beforeEach, and stable locators. - •Add assertions that reflect user-visible behavior and API contracts.
- •Keep tests deterministic and parallel-safe.
Key Conventions
- •Keep UI specs in
tests/*.spec.tsand API specs intests-api/*.test.ts. - •Prefer page objects in
lib/pagesand components inlib/components. - •Use
getByTestIdwithdata-testattributes (see config). - •Use
constants.tsfor UI base URL and credentials, andconstants-api-tests.tsfor API base URL. - •Use
tests/auth.setup.tsand storage state for authenticated UI flows. - •Use
test.use({ storageState: { cookies: [], origins: [] } })for unauthenticated UI tests. - •Avoid leaving
test.onlyin committed code.
When Adding Pages or Components
- •Extend
BasePageand expose small, composable methods. - •Keep locators private and stable.
- •Add reusable UI pieces as components in
lib/components.
Checks Before Finishing
- •Ensure test titles describe user-visible behavior.
- •Prefer
expect(locator).to...over rawpagechecks. - •Keep tests independent for
fullyParallelexecution. - •Add or update API types in
tests-api/types/types.tswhen adding payloads.
References
- •
references/repo-patterns.mdfor repo map, auth setup, and examples. - •
references/templates.mdfor UI/API/page object skeletons.