π Live Report: nayeemjohny.github.io/rolevault-ui-playwright-typescript-automation
- Overview
- Tech Stack
- Key Features
- Code Quality & Standards
- Advanced Test Fixtures
- Project Structure
- How to Run Tests
This repository contains Playwright end-to-end tests for the RoleVault UI, written in TypeScript. The framework focuses on readable Page Object Models (POM), reusable fixtures, cross-browser coverage, and rich reporting (Playwright HTML report + Allure).
- Professional-grade E2E test framework using Playwright + TypeScript
- Page Object Model (POM) with clear, reusable page classes and helpers
- Smart fixtures for session/auth management, automatic screenshots on failure, and optional video recording
- Storage state management - Authentication state persistence with role-based caching for optimized test execution
- Enhanced network monitoring - Per-page network request tracking with detailed reports and automatic attachment
- Component and E2E test patterns with consistent fixtures and utilities
- Cross-browser testing: Chromium (Google Chrome), Firefox, WebKit (Safari) and mobile emulation
- Multi-environment support: dynamic base URLs, env-specific timeouts/retries
- Configurable retries and timeouts per environment and CI
- CI/CD Integration: Seamless integration with GitHub Actions, Jenkins, and other CI/CD pipelines
This framework includes production-ready GitHub Actions workflows for automated testing:
Workflows Available:
- Code Analysis - Automated ESLint validation on PRs with auto-fix
- Test Execution - Full test suite execution with scheduled runs
- Sharded Execution - Parallel test execution with configurable sharding
Key CI Features:
- Scheduled test runs (Monday-Friday at 5:30 AM UTC)
- Manual workflow triggers with environment selection (staging/prod)
- Docker-based test environment (MongoDB + RoleVault application)
- Automated report generation (Playwright HTML + Allure)
- GitHub Pages deployment for test reports
- Test artifact retention (30 days)
- Parallel execution support with customizable shard percentage
Workflow Capabilities:
# Test Execution Options
- Environment: staging | prod
- CLI Arguments: Custom Playwright CLI options
- Report Publishing: Automatic deployment to GitHub Pages
- Sharding: Configurable work distribution (e.g., 25% = 4 shards)
CI Artifacts: All test runs automatically generate and preserve artifacts for 30 days:
- Playwright HTML reports
- Allure analytics reports
- Screenshots (on failures)
- Network request/response logs
- Test execution traces
- Application logs
Access artifacts via the GitHub Actions workflow run summary page.
- Visual testing support: screenshots and video capture on failures
- Rich reporting: Playwright HTML report and Allure analytics with detailed insights
- Network monitoring: Comprehensive HTTP request/response tracking with JSON reports for debugging
- Session isolation: Each test session runs in independent browser contexts for reliable test execution
- CI-friendly: easy to preserve artifacts (reports, videos, traces) for pipeline debugging
- Simple local demo site (see
github-pages/index.html
) that summarizes architecture and links to generated reports
This framework enforces high code quality through automated linting and formatting:
- TypeScript-specific rules: Prevents common async/await pitfalls and type issues
- Consistent code style: Enforces curly braces, strict equality, and clean arrow functions
- Best practices: Complexity limits, explicit return types, and proper error handling
- Pre-test validation: Automatically runs ESLint before test execution via
pretest
script
- Integrated with ESLint: Prettier runs as an ESLint rule for seamless formatting
- Consistent formatting: Single quotes, semicolons, 2-space indentation, 120 character line width
- Auto-fixable: Most style issues can be automatically corrected
// TypeScript Best Practices
- No floating promises (all async operations handled)
- Consistent type imports (import type for types)
- Explicit function return types
- No misused promises in conditionals
// Style Consistency
- Single quotes, semicolons required
- Max 1 empty line between code blocks
- No trailing spaces
- Complexity limit: 10 per function
# Automatic linting before tests
npm pretest
# Manual linting with auto-fix
npx eslint . --fix
This framework implements a sophisticated fixture system that provides powerful capabilities for test execution:
app
fixture: Pre-initialized application instance for simple test scenariossession
fixture: Advanced session factory for creating isolated test contexts with role-based authentication
Storage State Management
- Automatically caches authentication state by role (Administrator, Manager, Viewer)
- Reuses saved sessions across tests, eliminating redundant login operations
- Dramatically reduces test execution time (first login saved, subsequent tests reuse state)
- STORAGE_STATE_DIR: .auth (authentication storage states are saved under the
.auth
folder; configure via constants.STORAGE_STATE_DIR)
Per-Page Network Monitoring
- Captures all HTTP requests/responses for every page and session
- Generates detailed JSON reports with timing, headers, status codes, and payloads
- Automatically attached to test reports for debugging
Automatic Screenshot Capture
- Takes full-page screenshots on test failures
- Captures screenshots for all active sessions (main page + additional sessions)
- Properly named and attached to test reports
Session Isolation
- Each
session()
call creates an independent browser context - Perfect for multi-user scenarios (e.g., Admin creates user, new user logs in)
- No cross-contamination between test sessions
test('Multi-user workflow', async ({ session }) => {
// Admin session with cached auth
const admin = await session({ role: 'Administrator' });
// Create a new user
await admin.usersPage.addUser(newUser);
// New user session (independent context)
const newUserApp = await session();
await newUserApp.homePage.login(newUser);
});
Below is a tree view of the repository layout with descriptions of each component:
rolevault-ui-playwright-typescript-automation/
β
βββ π Configuration Files
β βββ constants.ts # Project-wide constants (URLs, test credentials, etc.)
β βββ eslint.config.mjs # ESLint configuration for TypeScript codebase
β βββ package.json # npm scripts and dependencies
β βββ playwright.config.ts # Playwright runner configuration (projects, timeouts, reporters)
β βββ tsconfig.json # TypeScript compiler settings
β βββ README.md # Project documentation
β
βββ π€ CI/CD Workflows
β βββ .github/workflows/
β βββ code-analysis.yml # ESLint validation & auto-fix on PRs
β βββ playwright-ci.yml # Scheduled & manual test execution
β βββ playwright-ci-sharding.yml # Parallel test execution with sharding
β
βββ π§ͺ Test Framework
β βββ fixtures/ # Test fixtures & shared test setup
β β βββ base.ts # Base fixtures and helpers used by tests
β β βββ storageState.ts # Storage state management for auth persistence
β β
β βββ pages/ # Page Object Model classes
β β βββ common/ # Shared locators, components, and helpers
β β
β βββ tests/ # Playwright test specifications
β β βββ components/ # Component-level or small-unit UI tests
β β βββ e2e/ # Full end-to-end user flows
β β
β βββ test-data/ # Test data fixtures, sample users and inputs
β βββ utils/ # Utility helpers (formatters, retry helpers, crypto)
β βββ helper.ts # General utility functions
β βββ networkMonitor.ts # Network request/response tracking
β
βββ π Reports & Artifacts
β βββ .auth/ # Cached authentication storage states (gitignored)
β βββ allure-report/ # Generated Allure HTML report (artifact folder)
β βββ allure-results/ # Raw Allure results (JSON, attachments)
β βββ playwright-report/ # Generated Playwright HTML report (artifact folder)
β βββ screenshots/ # Saved screenshots from test runs
β βββ test-results/ # Test runner outputs and structured results
β βββ network-reports/ # HTTP request/response logs with timing data
β
βββ π Documentation Site
βββ github-pages/ # Static demo/overview site
βββ index.html # Project overview page (architecture, features, report links)
βββ styles.css # Custom styles for documentation site
- Install dependencies:
npm ci
- Run all tests:
npx playwright test
- Run last-failed tests for a specific project (example: Google Chrome):
npx playwright test --project "Google Chrome" --last-failed
- Repeat each test multiple times (helpful for flaky-checks):
npx playwright test --repeat-each=5
- Run tests in UI mode (headed) with a single worker:
npx playwright test --ui --headed --workers=1
- Open the Playwright HTML report locally:
npx playwright show-report