A sandbox Angular application for mastering Playwright end-to-end testing. This repo includes various test scenarios, UI components, and best practices for writing reliable browser automation tests.
- Angular 14 app with TypeScript for realistic testing
- Pre-configured Playwright test suite with examples
- Diverse test scenarios covering:
- Form interactions & validations
- Dynamic content loading (API mocking)
- Authentication flows
- Visual regression tests
- Component isolation tests
- CI/CD-ready with GitHub Actions example
This project uses a PageManager entrypoint to keep tests clean and composable:
page-objects/pageManager.ts: central factory that exposes all page objects.page-objects/navigationPage.ts: navigation helpers for menu routing.page-objects/formLayoutsPage.ts: form interactions and reusable submit flows.page-objects/datepickerPage.ts: datepicker interactions and reusable date logic.test-options.ts: custom fixtures for wiringPageManagerinto tests.
The intended test flow is:
- Use
PageManagerin the test. - Navigate through
navigationPagehelpers. - Execute domain actions through page-object methods.
- Keep assertions in tests unless an assertion is tightly coupled to a page-object action.
- Clone the repo:
git clone https://github.com/ahasan09/playwright-practice-app cd playwright-practice-app - Install dependencies:
npm install
- Install Playwright browsers:
npx playwright install
- Run the Angular app (http://localhost:4200):
ng serve
- Run Playwright tests:
npm test
- Run all tests:
npm test - Run Playwright UI mode:
npm run test:ui - Run headed Chromium:
npm run test:headed - Run browser-specific suites:
npm run test:chromiumnpm run test:firefoxnpm run test:webkitnpm run test:all-browsers
- Update visual snapshots:
npm run test:update-snapshots - Open Playwright HTML report:
npm run test:report - Generate/open Allure reports:
npm run allure:generatenpm run allure:open
- Lint Playwright/page-object TypeScript files:
npm run lint:tests
The workflow in .github/workflows/playwright.yml now includes:
- Dependency + Playwright browser installation.
- Parallelized test execution using Playwright sharding.
- Blob report upload per shard.
- Post-processing job to merge shard reports into a single HTML report artifact.
CI artifact:
playwright-html-report(Playwright merged HTML report)
- Error-state tests for validation and API failure handling.
- Visual regression tests with
toHaveScreenshot(). - Accessibility checks using
@axe-core/playwright. - Existing API mocking patterns are kept and extended through route interception tests.
json-server is configured with sample data at mock-api/db.json.
- Start only mock API:
npm run mock-api - Start mock API + Angular app together:
npm run start:with-mock-api
- Parallel test execution
- Mobile viewport testing
- Video recording of test runs
- HTML report generation
- Fork the repository
- Create a branch (git checkout -b feature/your-feature)
- Commit changes (git commit -m 'Add some feature')
- Push to branch (git push origin feature/your-feature)
- Open a Pull Request