A comprehensive TypeScript-based test automation framework using Playwright with advanced reporting, logging, and Page Object Model patterns.
- TypeScript Support - Full TypeScript integration with strong typing
- Page Object Model - Organized, maintainable test structure
- Custom Fixtures - Reusable page objects and test utilities
- Multiple Reporters - HTML, JUnit, Allure, and Smart Reporter
- Advanced Logging - Custom logger with file and console output
- Parallel Execution - Run tests across multiple projects
- CI/CD Ready - GitHub Actions integration
- Screenshot & Video - Automatic capture on failure
- Multiple Browsers - Chromium, Firefox, WebKit support
- Code Quality - ESLint and Prettier configuration
- Node.js >= 18.x
- npm >= 9.x
- Allure (optional, for Allure reports)
# Clone the repository
git clone <repository-url>
cd playwright-typescript-example
# Install dependencies
npm install
# Install Playwright browsers
npx playwright installplaywright-typescript-example/
βββ src/
β βββ fixtures/ # Custom Playwright fixtures
β β βββ PageFixtures.ts # Page object fixtures
β βββ pages/ # Page Object Model
β β βββ BasePage.ts # Base page with common methods
β β βββ wikipedia/ # Wikipedia page objects
β βββ tests/ # Test files
β β βββ ExampleTestAPI.ts # API test examples
β β βββ ExampleTestUI.ts # UI test examples
β βββ utils/ # Utility classes
β βββ AllureHelper.ts # Allure reporting utilities
β βββ Logger.ts # Custom logging utility
β βββ PlaywrightTestListener.ts # Custom test listener
βββ reports/ # Test reports output
β βββ allure-results/ # Allure test results
β βββ playwright-report/ # HTML report
β βββ smart-reports/ # Smart reporter output
β βββ test-results/ # Test artifacts & JUnit XML
βββ logs/ # Application logs
βββ playwright.config.ts # Playwright configuration
βββ tsconfig.json # TypeScript configuration
βββ package.json # Project dependencies
# Run all tests in headless mode (pipeline project)
npx playwright test --project=pipeline
# Run all tests in headed mode (local project)
npx playwright test --project=local# Run tests by name pattern
npx playwright test --grep="Wikipedia Navigation Test"
# Run tests in a specific file
npx playwright test src/tests/ExampleTestUI.ts
# Run API tests only
npx playwright test src/tests/ExampleTestAPI.ts# Run with Allure reporter
npm run test-local-allure
# Run pipeline tests with Allure
npm run test-pipeline-allure# Open the last HTML report
npx playwright show-report reports/playwright-report# Generate Allure report
npm run allure:generate
# Open generated report
npm run allure:open
# Generate and serve report in one command
npm run allure:serveSmart reports are automatically generated at reports/smart-reports/smart-report.html
The framework uses two project configurations defined in playwright.config.ts:
- local - Headed mode with slow motion for local development
- pipeline - Headless mode optimized for CI/CD
Tests are matched using the pattern **/*Test*.ts, so name your test files accordingly:
ExampleTestUI.tsβExampleTestAPI.tsβ
Configure behavior via environment variables:
CI- Set to enable CI-specific settings (retries, workers)
// src/pages/MyPage.ts
import { Page, Locator } from '@playwright/test';
import { BasePage } from './BasePage';
export class MyPage extends BasePage {
readonly myButton: Locator;
constructor(page: Page) {
super(page);
this.myButton = this.page.locator('#my-button');
}
async clickButton(): Promise<void> {
await this.myButton.click();
}
}// src/tests/MyTest.ts
import { expect } from '@playwright/test';
import { test } from '../fixtures/PageFixtures';
test('my test', async ({ wikipediaHomePage, page }) => {
await wikipediaHomePage.navigate();
expect(page.url()).toContain('wikipedia');
});await test.step('Step 1: Navigate to homepage', async () => {
await page.goto('https://example.com');
await testInfo.attach('step-1-screenshot', {
body: await page.screenshot(),
contentType: 'image/png'
});
});# Run ESLint
npm run lint
# Fix ESLint issues
npm run lint:fix
# Format and lint in one command
npm run checkThe framework includes GitHub Actions workflow (.github/workflows/playwright.yml) for:
- Automated test execution
- Multiple browser support
- Artifact collection
- Report generation
Additional documentation is available in the docs/ folder:
- Getting Started Guide
- Architecture Overview
- Page Object Model Guide
- Custom Utilities
- Reporting Guide
- Create a feature branch
- Make your changes
- Run
npm run checkto ensure code quality - Write/update tests for new features
- Submit a pull request
MIT
Playwright TypeScript Example Team
For more information, visit the Playwright documentation


