@@ -71,25 +71,65 @@ Tooling required:
7171
7272### Available Scripts
7373
74- | Command | Description |
75- | ----------------- | ----------------------------------------- |
76- | ` npm run dev ` | Start development server with hot reload |
77- | ` npm run build ` | Build production site to ` ./dist ` |
78- | ` npm run preview ` | Preview production build locally |
79- | ` npm run lint ` | Run ESLint to check for issues |
80- | ` npm run check ` | Run type checking and format verification |
74+ | Command | Description |
75+ | ------------------ | ----------------------------------------- |
76+ | ` npm run dev ` | Start development server with hot reload |
77+ | ` npm run build ` | Build production site to ` ./dist ` |
78+ | ` npm run preview ` | Preview production build locally |
79+ | ` npm run lint ` | Run ESLint to check for issues |
80+ | ` npm run check ` | Run type checking and format verification |
81+ | ` npm run test:e2e ` | Run Playwright E2E tests |
8182
8283## Submitting a Pull Request
8384
84- 1 . Create a new branch from ` main `
85- 2 . Make your changes
86- 3 . Run ` npm run check ` to verify code style and types
87- 4 . Commit with a clear message
88- 5 . Push to your fork
89- 6 . Open a PR against ` main `
85+ 1 . Create a new branch from ` main ` .
86+ 2 . Make your changes.
87+ 3 . Run ` npm run check ` to verify code style and types.
88+ 4 . Run ` npm run test:e2e ` to ensure your changes don't break existing functionality.
89+ 5 . Commit with a clear message.
90+ 6 . Push to your fork.
91+ 7 . Open a PR against ` main ` .
9092
9193> Ensure all checks pass and your branch is up to date with ` main ` before opening a PR.
9294
95+ ## Testing
96+
97+ We use ** Playwright** for End-to-End (E2E) testing. All PRs are automatically tested against a Netlify Preview deployment before they can be merged.
98+
99+ ### Prerequisites
100+
101+ Before running E2E tests for the first time, you need to install the browser binaries:
102+
103+ ``` bash
104+ npx playwright install --with-deps
105+ ```
106+
107+ ### Running Tests Locally
108+
109+ You can run the full test suite against your local development server:
110+
111+ 1 . In one terminal, start the site: ` npm run dev `
112+ 2 . In another terminal, run the tests: ` npm run test:e2e `
113+
114+ ### Writing Stable Tests
115+
116+ When adding new tests or modifying components, please follow these stability guidelines:
117+
118+ 1 . ** Avoid CSS Classes** : Do not use CSS classes (e.g., ` .hero__content ` ) for locators, as they are fragile and change during refactoring.
119+ 2 . ** Use data-testid** : Add ` data-testid ` attributes to components for stable targeting (e.g., ` <div data-testid="my-component"> ` ).
120+ 3 . ** User-Visible Locators** : Prefer semantic locators like ` getByRole ` , ` getByText ` , or ` getByAltText ` over IDs when possible.
121+
122+ Example:
123+
124+ ``` typescript
125+ // Good: Stable and accessible
126+ const logo = page .getByAltText (' Express.js logo' );
127+ const section = page .getByTestId (' features-section' );
128+
129+ // Bad: Fragile
130+ const logo = page .locator (' .hero__logo' );
131+ ```
132+
93133## Further Documentation
94134
95135For more detailed documentation about the project, see the [ ` docs/ ` ] ( docs/ ) folder:
0 commit comments