A comprehensive end-to-end testing framework built with Playwright, TypeScript, and Allure reporting. Features automatic GitHub Pages deployment for test reports.
- Playwright Test - Modern E2E testing framework
- TypeScript - Type-safe test development
- Allure Reporting - Beautiful, interactive test reports
- GitHub Pages - Automatic report deployment
- Page Object Pattern - Maintainable test architecture
- API Testing - Built-in API client wrapper
- ESLint + Prettier - Code quality and formatting
- CI/CD Ready - GitHub Actions workflow included
playwright/
βββ .github/
β βββ workflows/
β βββ ci.yml # GitHub Actions workflow
βββ api/
β βββ client/
β β βββ api-client.ts # API client wrapper
β β βββ index.ts
β βββ models/
β β βββ post.model.ts # API response models
β β βββ user.model.ts
β β βββ index.ts
β βββ index.ts
βββ config/
β βββ env.config.ts # Environment configuration
β βββ index.ts
βββ fixtures/
β βββ test.fixture.ts # Custom test fixtures
β βββ index.ts
βββ pages/
β βββ base.page.ts # Base page object
β βββ google.page.ts # Google search page object
β βββ index.ts
βββ tests/
β βββ api/
β β βββ posts.spec.ts # API tests for posts
β β βββ users.spec.ts # API tests for users
β βββ ui/
β βββ google-search.spec.ts # UI tests
βββ utils/
β βββ allure-helper.ts # Allure utilities
β βββ data-generator.ts # Test data generators
β βββ index.ts
βββ .eslintrc.json # ESLint configuration
βββ .gitignore
βββ .prettierrc # Prettier configuration
βββ .prettierignore
βββ env.example # Environment variables template
βββ package.json
βββ playwright.config.ts # Playwright configuration
βββ tsconfig.json # TypeScript configuration
βββ README.md
- Node.js 18+
- npm or yarn
-
Clone the repository
git clone <repository-url> cd playwright
-
Install dependencies
npm ci # or npm install -
Install Playwright browsers
npx playwright install --with-deps # or install specific browser npx playwright install chromium --with-deps -
Configure environment (optional)
cp env.example .env # Edit .env with your settings
npm testnpm run test:uinpm run test:apinpm run test:headednpm run test:debugnpm run test:cinpm run allure:generatenpm run allure:opennpm run allure:servenpm run lintnpm run lint:fixnpm run formatnpm run format:check| Script | Description |
|---|---|
npm test |
Run all tests |
npm run test:ui |
Run UI tests only |
npm run test:api |
Run API tests only |
npm run test:headed |
Run tests with browser visible |
npm run test:debug |
Run tests in debug mode |
npm run test:ci |
Run tests in CI mode with Allure |
npm run allure:generate |
Generate Allure report |
npm run allure:open |
Open Allure report |
npm run allure:serve |
Generate and serve Allure report |
npm run lint |
Run ESLint |
npm run lint:fix |
Fix ESLint issues |
npm run format |
Format code with Prettier |
npm run format:check |
Check code formatting |
Create a .env file in the project root:
# Base URL for UI tests
BASE_URL=https://www.google.com
# Base URL for API tests
API_BASE_URL=https://jsonplaceholder.typicode.com
# Run tests in headless mode
HEADLESS=true
# Browser to use (chromium, firefox, webkit)
BROWSER=chromium
# Enable debug mode
DEBUG=falseThe project includes a GitHub Actions workflow that:
- Runs on: Push to
main/master, Pull Requests, Manual trigger - Installs: Node.js, dependencies, Playwright browsers
- Runs: All Playwright tests
- Generates: Allure report
- Deploys: Report to GitHub Pages
- Go to your repository Settings β Pages
- Under Build and deployment, select GitHub Actions
- Push to
mainbranch to trigger deployment - Report URL:
https://<owner>.github.io/<repo>/
After each workflow run, the following artifacts are available:
playwright-report- Playwright HTML reportallure-results- Raw Allure resultsallure-report- Generated Allure reporttest-results- Traces, screenshots, videos
- Create a Page Object (if needed):
// pages/example.page.ts
import { Page, Locator } from '@playwright/test';
import { BasePage } from './base.page';
export class ExamplePage extends BasePage {
protected readonly pageUrl = '/example';
protected readonly pageName = 'Example Page';
private readonly submitButton: Locator;
constructor(page: Page) {
super(page);
this.submitButton = page.locator('button[type="submit"]');
}
async clickSubmit(): Promise<void> {
await this.clickElement(this.submitButton, 'Submit Button');
}
}- Export from index:
// pages/index.ts
export * from './example.page';- Add fixture (if needed):
// fixtures/test.fixture.ts
import { ExamplePage } from '../pages';
export interface TestFixtures {
// ... existing fixtures
examplePage: ExamplePage;
}
export const test = base.extend<TestFixtures>({
// ... existing fixtures
examplePage: async ({ page }, use) => {
const examplePage = new ExamplePage(page);
await use(examplePage);
},
});- Write the test:
// tests/ui/example.spec.ts
import { test, expect } from '../../fixtures';
import { setTestMetadata, Severity } from '../../utils';
test.describe('Example Feature', () => {
test('should do something', async ({ examplePage }) => {
await setTestMetadata({
feature: 'Example',
story: 'Basic functionality',
severity: Severity.NORMAL,
owner: 'QA Team',
});
await examplePage.goto();
await examplePage.clickSubmit();
// assertions...
});
});// tests/api/example.spec.ts
import { test, expect } from '@playwright/test';
import { ApiClient } from '../../api';
import { setTestMetadata, Severity, attachJson } from '../../utils';
test.describe('Example API', () => {
let apiClient: ApiClient;
test.beforeEach(async ({ request }) => {
apiClient = new ApiClient(request);
});
test('GET /endpoint', async () => {
await setTestMetadata({
feature: 'Example API',
story: 'Get data',
severity: Severity.CRITICAL,
});
const response = await apiClient.get('/endpoint');
expect(response.status).toBe(200);
await attachJson('Response', response.data);
});
});The framework supports various Allure annotations:
import { setTestMetadata, Severity } from '../../utils';
await setTestMetadata({
feature: 'Feature Name', // @allure.label.feature
story: 'User Story', // @allure.label.story
epic: 'Epic Name', // @allure.label.epic
severity: Severity.CRITICAL, // @allure.label.severity
owner: 'QA Team', // @allure.label.owner
tag: 'smoke', // @allure.label.tag
description: 'Test description',
});Severity.BLOCKER- Blocker defectsSeverity.CRITICAL- Critical functionalitySeverity.NORMAL- Normal prioritySeverity.MINOR- Minor issuesSeverity.TRIVIAL- Trivial issues
await googlePage.takeScreenshot('Screenshot name');import { attachJson } from '../../utils';
await attachJson('Response Data', responseObject);import { attachText } from '../../utils';
await attachText('Log', 'Some text content');- Fork the repository
- Create a feature branch
- Make your changes
- Run linting and tests
- Submit a pull request
MIT License - see LICENSE for details.