Dự án automation testing sử dụng Playwright, TypeScript, Nx monorepo với đầy đủ các công cụ CI/CD.
- Playwright - Framework testing end-to-end
- TypeScript - Ngôn ngữ lập trình
- Nx Monorepo - Workspace management
- ESLint - Code linting
- Prettier - Code formatting
- Husky - Git hooks
- GitHub Actions - CI/CD pipeline
automation-project/
├── apps/
│ └── e2e-tests/ # Playwright E2E tests
│ ├── e2e/ # Test files
│ ├── playwright.config.ts
│ └── ...
├── .github/
│ └── workflows/
│ └── ci.yml # CI/CD pipeline
├── .husky/ # Git hooks
├── .eslintrc.json # ESLint configuration
├── .lintstagedrc.json # Lint-staged configuration
├── .prettierrc # Prettier configuration
└── package.json
- Node.js (v18 trở lên)
- npm
- Clone repository:
git clone <repository-url>
cd automation-project
- Cài đặt dependencies:
npm install
- Cài đặt Playwright browsers:
npx playwright install
npm run test:e2e
npm run test:e2e:ui
npm run test:e2e:headed
npx nx e2e @automation-project/e2e-tests
# Chạy lint cho toàn bộ project
npm run lint
# Tự động fix linting issues
npm run lint:fix
# Lint cho project cụ thể
npx nx lint @automation-project/e2e-tests
# Format code
npm run format
# Kiểm tra formatting
npm run format:check
# Xem thông tin project
npx nx show project @automation-project/e2e-tests
# Chạy affected tests (chỉ test những file thay đổi)
npx nx affected --target=e2e
# Xem dependency graph
npx nx graph
Project sử dụng Husky để chạy pre-commit hooks:
-
Pre-commit: Tự động chạy lint-staged
- Lint và format code
- Kiểm tra TypeScript types
-
Push: CI/CD pipeline tự động chạy trên GitHub Actions
GitHub Actions workflow sẽ:
- Cài đặt dependencies
- Cài đặt Playwright browsers
- Chạy linting
- Kiểm tra code formatting
- Chạy E2E tests
- Upload test reports
import { test, expect } from '@playwright/test';
test.describe('Feature Name', () => {
test('should do something', async ({ page }) => {
await page.goto('https://example.com');
await expect(page).toHaveTitle(/Expected Title/);
});
});
- Sử dụng Page Object Model
- Tạo test data factories
- Sử dụng fixtures cho setup/teardown
- Tổ chức tests theo features
File: apps/e2e-tests/playwright.config.ts
- Root:
.eslintrc.json
- E2E specific:
apps/e2e-tests/.eslintrc.json
File: .prettierrc
- Fork repository
- Tạo feature branch
- Commit changes
- Push branch
- Tạo Pull Request
Nếu có vấn đề gì, vui lòng tạo issue trên repository.