A production-grade end-to-end test automation framework built with Playwright and TypeScript, targeting SauceDemo β a public eCommerce demo site. This project demonstrates real-world QA engineering practices including Page Object Model architecture, AI-augmented test generation, multi-browser execution, and automated CI/CD reporting.
- Overview
- Tech Stack
- Project Structure
- Getting Started
- Running Tests
- AI Integration
- CI/CD Pipeline
- Reporting
- Contributing
This framework covers the core user journeys of the SauceDemo eCommerce application:
- Authentication β valid login, invalid credentials, locked-out user, edge cases
- Product Catalog β sorting, filtering, product detail validation
- Shopping Cart β add/remove items, cart persistence, badge counts
- Checkout Flow β full order completion, form validation, order confirmation
- API Layer β endpoint validation where applicable
- AI-Augmented Testing β dynamic test data generation and scenario suggestion via OpenAI
The test suite is designed to run in CI on every push and PR, with smoke vs. full regression separation and Allure report artifacts published automatically.
| Layer | Technology |
|---|---|
| Test Runner | Playwright 1.50.x |
| Language | TypeScript 5.x |
| Architecture | Page Object Model (POM) |
| BDD Layer | Playwright Test (native) |
| API Testing | Playwright APIRequestContext |
| AI Integration | OpenAI API (gpt-4o-mini) |
| Reporting | Allure 2.x + Custom Reporter |
| CI/CD | GitHub Actions |
| Node Version | 20.x LTS |
playwright-saucedemo/
βββ .github/
β βββ workflows/
β βββ ci.yml # GitHub Actions pipeline
βββ src/
β βββ fixtures/
β β βββ base.fixture.ts # Extended Playwright fixtures
β βββ helpers/
β β βββ ai-test-helper.ts # OpenAI-powered test utilities
β β βββ api-helper.ts # API request utilities
β βββ pages/
β β βββ login.page.ts
β β βββ inventory.page.ts
β β βββ cart.page.ts
β β βββ checkout.page.ts
β β βββ checkout-complete.page.ts
β βββ test-data/
β βββ users.ts # User credentials and test accounts
β βββ products.ts # Product data and expectations
βββ tests/
β βββ auth/
β β βββ login.spec.ts
β βββ e2e/
β β βββ checkout-flow.spec.ts
β β βββ cart.spec.ts
β βββ catalog/
β β βββ product-sorting.spec.ts
β βββ api/
β βββ api-validation.spec.ts
βββ reports/
β βββ .gitkeep
βββ allure-results/
β βββ .gitkeep
βββ playwright.config.ts
βββ tsconfig.json
βββ package.json
βββ .env.example
βββ .gitignore
- Node.js 20.x or higher
- npm 9.x or higher
# Clone the repository
git clone https://github.com/yourusername/playwright-saucedemo.git
cd playwright-saucedemo
# Install dependencies
npm ci
# Install Playwright browsers
npx playwright install --with-deps
# Copy environment variables
cp .env.example .envEdit .env with your values. At minimum, BASE_URL is required. OPENAI_API_KEY is only needed if you want the AI helper features active.
npm testnpm run test:smokenpm run test:regressionnpx playwright test tests/auth/login.spec.tsnpx playwright test --headednpx playwright test --project=chromium
npx playwright test --project=firefox
npx playwright test --project=webkitnpx playwright test --uinpm run allure:generate
npm run allure:openThis framework includes an AITestHelper utility (src/helpers/ai-test-helper.ts) that integrates with the OpenAI API to augment the test suite with intelligent capabilities:
1. Dynamic Edge Case Generation Rather than hardcoding boundary-value inputs, the helper queries the model to generate realistic edge cases for a given field type (e.g., "email", "zip code", "name"). This surfaces test scenarios that manual analysis might miss.
2. Scenario Suggestion Given a plain-English description of a page or feature, the helper returns a list of test scenarios covering happy paths, negative cases, and edge conditions. Useful for rapid test planning on new features.
3. Post-Run Summaries After a test run, the helper can consume a results JSON and generate a human-readable summary describing pass/fail counts, flaky areas, and recommended follow-up. Suitable for dropping into a Slack message or PR comment.
Configuration:
Set OPENAI_API_KEY in your .env file. If the key is absent, the helper degrades gracefully and returns static fallback data so tests continue to run in CI without requiring the API.
Why this approach: The AI layer is intentionally kept as a utility class rather than embedded in test assertions. This keeps tests deterministic and reproducible β the AI is used for generating inputs and documentation, not for making pass/fail decisions.
The GitHub Actions workflow (.github/workflows/ci.yml) runs on every push and pull request to main and develop.
Jobs:
| Job | Trigger | Browsers | Description |
|---|---|---|---|
smoke |
push, PR | chromium | Fast sanity check β critical path only |
regression |
push to main, PR | chromium, firefox, webkit | Full suite across all browsers |
Artifacts:
- Allure report uploaded as a downloadable artifact on every run
- Screenshots automatically captured on test failure
- Test results JSON retained for 30 days
Environment secrets required:
BASE_URLβ defaults tohttps://www.saucedemo.comOPENAI_API_KEYβ optional, for AI helper features
After running tests locally:
npm run allure:generate # converts allure-results/ to allure-report/
npm run allure:open # opens the report in your browserThe Allure report includes:
- Test execution timeline
- Pass/fail/skip breakdown by suite
- Screenshots attached on failure
- Full step-by-step log per test
- Environment metadata (OS, browser, Node version)
A lightweight custom reporter (src/helpers/custom-reporter.ts) logs timestamped test results to the console and writes a reports/results.json summary file. This makes it easy to pipe results into other systems (Slack webhooks, TestRail, Jira, etc.).
[2026-03-15 09:14:32] β
PASSED login βΊ should login with valid credentials (1.2s)
[2026-03-15 09:14:34] β
PASSED login βΊ should show error for invalid password (0.8s)
[2026-03-15 09:14:35] β
PASSED login βΊ should block locked_out_user (0.6s)
[2026-03-15 09:14:38] β
PASSED checkout βΊ should complete full purchase flow (4.1s)
[2026-03-15 09:14:40] β FAILED checkout βΊ should show error for missing zip code (1.0s)
Run Summary: 24 passed, 1 failed, 0 skipped β 38.4s total
- Fork the repository
- Create a branch:
git checkout -b feature/your-feature-name - Follow the existing code style (ESLint + Prettier config)
- Write tests for any new page objects or helpers
- Submit a PR with a clear description of the change
Branch naming conventions used in this project:
feature/β new test coverage or utilitiesfix/β bug fixes in existing tests or helperschore/β config updates, dependency bumps, CI changesrefactor/β structural improvements without behavior change
MIT