playwright-test-workflow
Version:
Global test workflow package for Playwright with custom reporters
114 lines (87 loc) • 3.25 kB
Markdown
# Playwright Test Workflow
A global testing workflow package for Playwright that provides:
- Automated test grouping by serial numbers (TEST#1, TEST#2, etc.)
- Custom reporters for text and HTML output
- Separate reports for each test group
- Template files for consistent testing across projects
## Installation
```bash
# Install globally
npm install -g playwright-test-workflow
# Or install locally in your project
npm install --save-dev playwright-test-workflow
```
## Quick Start
```bash
# Initialize workflow in your project
test-workflow init my-app
# Run tests
npx playwright test
# Check results in test-results/ folder
```
## Features
### Custom Reporters
- **Text Reporter**: Generates simple text files with pass/fail status
- **HTML Reporter**: Creates beautiful HTML reports with styling
- **Group Reports**: Separate files for each test group (TEST#1, TEST#2, etc.)
### File Structure
```
your-project/
├── test.md # Test planning document
├── playwright.config.js # Playwright configuration
├── tests/ # Test files
├── test-results/ # Generated reports
│ ├── TEST#1-results.txt # Group-specific text report
│ ├── TEST#1-results.html # Group-specific HTML report
│ ├── TEST#2-results.txt
│ ├── TEST#2-results.html
│ └── test-results.json # Overall JSON report
└── reporters/ # Custom reporter files
```
## Usage
### 1. Initialize Workflow
```bash
test-workflow init [project-name]
```
### 2. Plan Your Tests
Edit `test.md` to add your specific test cases:
```markdown
### TEST#1 - Core Functionality
- [ ] Feature loads successfully
- [ ] Main functionality works as expected
### TEST#2 - User Interface
- [ ] UI elements display correctly
- [ ] User interactions are responsive
```
### 3. Write Tests
Create test files in `tests/` directory. The reporters automatically group tests based on keywords.
### 4. Run Tests
```bash
npx playwright test
```
### 5. Check Results
- Individual group reports: `test-results/TEST#1-results.txt`, `test-results/TEST#1-results.html`
- Overall reports: `test-results/test-results.json`, `playwright-report/index.html`
## Test Grouping Logic
Tests are automatically grouped based on keywords in test names:
- **TEST#1**: load, display, show, heading, button, input, result display
- **TEST#2**: calculate, sum, negative, zero, large, decimal
- **TEST#3**: empty, non-numeric, precision, error, validation
- **TEST#4**: responsive, clickable, accept, update, ui, ux
## Configuration
You can customize test grouping patterns in your `playwright.config.js`:
```javascript
reporter: [
['playwright-test-workflow/reporters/text-reporter.js', {
outputFile: 'test-results/test-results.txt',
testGroupPatterns: {
'TEST#1': ['login', 'auth', 'signup'],
'TEST#2': ['dashboard', 'navigation', 'menu'],
// ... custom patterns
}
}]
]
```
## Workflow
1. **Create Feature** → 2. **Update test.md** → 3. **Number Tests** → 4. **Run Tests** → 5. **Generate Reports** → 6. **Update test.md with Results**
Perfect for maintaining consistent testing across multiple projects!