A comprehensive, enterprise-grade test automation framework for SauceDemo using Playwright and TypeScript. This project demonstrates modern test automation best practices, scalable architecture, and professional CI/CD integration.
This framework showcases:
- Page Object Model (POM) design pattern for maintainable tests
- TypeScript for type safety and better developer experience
- Multi-browser testing (Chrome, Firefox, Safari)
- Cross-platform CI/CD (GitHub Actions & CircleCI)
- Professional reporting (Allure, Playwright HTML, JUnit)
- Code quality tools (ESLint, Prettier, TypeScript compiler)
- Mobile testing capabilities
- Parallel test execution with sharding
[Attach Test Strategy Document Here - PDF/Excel/Google Docs]
Key Focus Areas:
- Login functionality validation
- User role testing (standard, locked, problem, performance users)
- Negative test scenarios and edge cases
- Cross-browser compatibility
- Performance and visual regression detection
[Attach Test Plan Document Here - PDF/Excel/Google Docs]
Test Coverage:
- β Authentication & Authorization
- β³ Product Catalog & Inventory
- β³ Shopping Cart & Checkout
- β³ User Profile & Settings
- β³ Error Handling & Validation
[Attach Test Cases Document Here - Excel/CSV/Test Management Tool Export]
Current Implementation:
- Login functionality (6 user types + edge cases)
- Error message validation
- Page navigation flows
- UI element interactions
The following shows the structure of this auceDemo Playwright TypeScript Test Automation:
saucedemo-playwright-ts-tests/
βββ .circleci/ # CircleCI continuous integration configuration
β βββ config.yml # Defines CI/CD pipeline for CircleCI platform - runs tests on every push/PR
βββ .github/ # GitHub-specific configuration
β βββ workflows/ # GitHub Actions workflow definitions
β βββ playwright.yml # Automated test execution on GitHub infrastructure - runs on schedule and triggers
βββ allure-results/ # AUTO-GENERATED: Raw test results for Allure reports - contains test execution data
βββ allure-report/ # AUTO-GENERATED: HTML test reports generated by Allure - interactive test results dashboard
βββ pages/ # PAGE OBJECT MODEL: Contains classes representing each page in the application
β βββ base-page.ts # Abstract base class with common functionality inherited by all page objects
β βββ login-page.ts # Login page specific elements and methods - handles authentication flows
β βββ inventory-page.ts # Products inventory page - handles product listing, sorting, and cart operations
βββ tests/ # TEST SPECIFICATIONS: Contains all test files organized by functionality
β βββ home.spec.ts # Tests for basic navigation, page structure, and initial load validations
β βββ login.spec.ts # Comprehensive login functionality tests - positive, negative, and edge cases
βββ utils/ # UTILITY FUNCTIONS: Reusable helper methods and common test operations
β βββ test-data.ts # Centralized test data repository - users, error messages, URLs, timeouts
β βββ helpers.ts # Generic helper functions - random data generation, element checks, screenshots
β βββ common-steps.ts # Reusable test steps - login, logout, verification methods for BDD-like approach
βββ fixtures/ # TEST FIXTURES: Static test data sets for different test scenarios
β βββ test-data.ts # Predefined data sets for login tests - valid/invalid credentials, edge cases
βββ types/ # TYPE DEFINITIONS: TypeScript interfaces and type definitions for type safety
β βββ index.ts # Main exports barrel file - aggregates all type definitions for easy importing
β βββ user.types.ts # User-related interfaces - credentials, profiles, sessions, roles, and permissions
β βββ page.types.ts # Page-related interfaces - products, carts, navigation, forms, and UI elements
β βββ test.types.ts # Test-related interfaces - configurations, results, suites, and performance metrics
β βββ api.types.ts # API-related interfaces - request/response structures, errors, pagination (future use)
βββ .eslintrc.js # ESLint configuration - code quality rules, TypeScript support, and formatting standards
βββ .gitignore # Git ignore rules - excludes generated files, dependencies, and sensitive data from version control
βββ package.json # Project configuration - dependencies, scripts, metadata, and npm package information
βββ playwright.config.ts # Playwright test runner configuration - browsers, reporters, timeouts, and global settings
βββ tsconfig.json # TypeScript compiler configuration - strict type checking, module resolution, and output settings
βββ README.md # Project documentation - setup instructions, usage guide, and architecture overview
playwright.config.ts- Main Playwright configuration (browsers, reporters, timeouts)tsconfig.json- TypeScript compiler settings with strict type checkingeslint.config.js- ESLint configuration using modern ES modulespackage.json- Project metadata, dependencies, and npm scripts
.github/workflows/playwright.yml- GitHub Actions workflow with scheduled runs.circleci/config.yml- CircleCI configuration with parallel jobs
tests/specs/- Actual test files organized by featuretests/pages/- Page Object Model classes for each pagetests/utils/- Reusable utilities, helpers, and custom commandstests/fixtures/- Test data, mock data, and fixturesconfig/environment.ts- Environment-specific configurations
allure-report/- Detailed Allure test reports with trends and historyplaywright-report/- Playwright's built-in HTML test reportertest-results/- Videos, screenshots, and trace files for failed tests
- Node.js 18 or higher
- npm (comes with Node.js)
- Git
-
Clone the repository
git clone https://github.com/SabineU/saucedemo-playwright-ts-tests.git cd saucedemo-playwright-ts-tests -
Install dependencies
npm ci
-
Install Playwright browsers
npx playwright install
-
Install Playwright browsers
npx playwright install
-
Basic Test Execution
# Run all tests in headless mode npm test # Run tests with browser UI visible npm run test:headed # Run tests in debug mode npm run test:debug
-
Interactive Test Development
# Open Playwright Test Runner UI npm run test:ui # Generate tests using Codegen (record user actions) npm run test:codegen
-
Advanced Test Execution
# Run tests on specific browsers only npx playwright test --project=chromium npx playwright test --project=firefox npx playwright test --project=webkit # Run tests in parallel (4 workers) npx playwright test --workers=4 # Run tests matching a tag or name pattern npx playwright test --grep="@login" npx playwright test --grep="should validate error messages"
-
Report Generation
# View latest test report npm run test:report # Generate Allure report npm run allure:generate # Serve Allure report locally npm run allure:serve
-
π§ Code Quality & Maintenance
# Run ESLint to check code quality npm run lint # Auto-fix ESLint issues npm run lint:fix # TypeScript type checking (no compilation) npm run type-check # Clear all generated reports and results npm run allure:clear
This framework generates multiple types of reports:
-
Playwright HTML Report
npm run test:report
- Interactive HTML report with test results
- Screenshots and videos for failed tests
- Test timeline and execution details
-
Allure Reports
npm run allure:generate npm run allure:serve
- Professional test reporting with trends
- Historical data and analytics
- Rich attachments and environment info
## CI/CD Integration
- JUnit XML for CI systems (Jenkins, etc.)
- GitHub Actions artifacts with test results
- CircleCI test insights and timing analytics
- GitHub Actions
- Trigger: On push/PR to main/master + scheduled daily runs
- Jobs: Code quality checks β Parallel test execution
- Artifacts: Test reports, videos, screenshots
- Schedule: Weekdays at 8:00 AM (GMT+2)
- CircleCI
- Workflows: On-demand testing + scheduled afternoon runs
- Parallelism: Multi-container test execution
- Caching: Optimized dependency installation
- Artifacts: Comprehensive test results storage
- β Best Practices Implemented
- Type Safety: Full TypeScript implementation with strict mode
- Code Quality: ESLint with TypeScript rules and Prettier formatting
- Page Object Model: Clean separation of test logic and page interactions
- Environment Configuration: Configurable base URLs and test data
- Error Handling: Comprehensive error catching and reporting
- Parallel Execution: Fast test runs through sharding and workers
- π Security & Maintenance
- Dependency Management: Regular updates with npm ci for consistency
- Secret Management: Environment variables for sensitive data
- Artifact Retention: Automatic cleanup after 30 days
- Resource Optimization: Efficient browser management and caching
- π€ Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# 1. Run tests to ensure everything works
npm test
# 2. Check code quality
npm run lint
# 3. Verify TypeScript types
npm run type-check
# 4. Run tests in UI mode for new features
npm run test:ui
This project is licensed under
GitHub Profile: https://github.com/SabineU
- Playwright (https://playwright.dev/) for the excellent testing framework
- SauceDemo (https://www.saucedemo.com/) for providing a great test application
- Allure Report (https://allurereport.org/) for beautiful test reporting
- GitHub Actions and CircleCI for robust CI/CD pipelines
β If you find this project helpful, please give it a star! β