Development
test-engineer
Automated E2E testing with Playwright including the auto-fix loop — generate test cases from the UI, run them, fix failures and re-run until passing, then produce a human-readable report. Test until it passes, not just test and report. Drives /toh-test; use whenever tests must be written, run, or made green.
wasintoh · AI review on file
Installation
Read the source and dependencies before running a command. Copying does not install or execute anything.
npx skills add wasintoh/toh-framework --skill test-engineerAbout this skill
name: test-engineer description: > Automated E2E testing with Playwright including the auto-fix loop — generate test cases from the UI, run them, fix failures and re-run until passing, then produce a human-readable report. Test until it passes, not just test and report. Drives /toh-test; use whenever tests must be written, run, or made green. user-invocable: false # internal — model-invoked via toh-* commands, not a user /command
Test Engineer Skill
Overview
Skill for automated testing with Playwright, including auto-fix loop capability.
Core Philosophy
"Test until it passes, not just test and report"
- Auto-Generate Tests - Generate test cases from UI automatically
- Auto-Fix Loop - If fails, fix and re-test until passing
- Human-Readable Reports - Easy to understand reports
- Language-Adaptive - Error messages adapt to project language setting
Tech Stack
| Tool | Purpose |
|---|---|
| Playwright | E2E Testing |
| @playwright/test | Test Runner |
| playwright-report | HTML Reports |
Setup
1. Install Playwright
npm install -D @playwright/test
npx playwright install
2. Config File
Create playwright.config.ts:
import { defineConfig, devices } from '@playwright/test'
export default defineConfig({
testDir: './tests',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [
['html'],
['list']
],
use: {
baseURL: 'http://localhost:3000',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'Mobile Chrome',
use: { ...devices['Pixel 5'] },
},
],
webServer: {
command: 'npm run dev',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
},
})
3. Test Directory Structure
tests/
├── auth/
│ ├── login.spec.ts
│ └── register.spec.ts
├── dashboard/
│ └── dashboard.spec.ts
├── products/
│ ├── list.spec.ts
│ └── detail.spec.ts
├── checkout/
│ └── flow.spec.ts
└── fixtures/
└── test-data.ts
Test Generation Patterns
Pattern 1: Page Render Test
Every page must have a test to verify correct rendering:
import { test, expect } from '@playwright/test'
test.describe('Products Page', () => {
test('should render correctly', async ({ page }) => {
await page.goto('/products')
// Check title
await expect(page).toHaveTitle(/Products/)
// Check main heading
await expect(
page.getByRole('heading', { name: 'All Products' })
).toBeVisible()
// Check key elements exist
await expect(page.getByTestId('product-grid')).toBeVisible()
await expect(page.getByRole('searchbox')).toBeVisible()
})
})
Pattern 2: Form Validation Test
Every form must have validation tests:
test.describe('Register Form', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/register')
})
test('should show validation errors for empty fields', async ({ page }) => {
// Click submit without filling
await page.getByRole('button', { name: 'Register' }).click()
// Check error messages
await expect(page.getByText('Name is required')).toBeVisible()
await expect(page.getByText('Email is required')).toBeVisible()
await expect(page.getByText('Password is required')).toBeVisible()
})
test('should validate email format', async ({ page }) => {
await page.getByLabel('Email').fill('invalid-email')
await page.getByRole('button', { name: 'Register' }).click()
await expect(page.getByText('Invalid email format')).toBeVisible()
})
test('should validate password strength', async ({ page }) => {
await page.getByLabel('Password').fill('123')
await page.getByRole('button', { name: 'Register' }).click()
await expect(page.getByText('Password must be at least 8 characters')).toBeVisible()
})
})
Pattern 3: User Flow Test
Test complete user journey:
test.describe('Checkout Flow', () => {
test('should complete purchase successfully', async ({ page }) => {
// Step 1: Browse products
await page.goto('/products')
await expect(page.getByTestId('product-card')).toHaveCount.greaterThan(0)
// Step 2: Add to cart
await page.getByTestId('product-card').first().click()
await page.getByRole('button', { name: 'Add to Cart' }).click()
await expect(page.getByTestId('cart-count')).toHaveText('1')
// Step 3: Go to cart
await page.getByTestId('cart-icon').click()
await expect(page).toHaveURL('/cart')
await expect(page.getByTestId('cart-item')).toHaveCount(1)
// Step 4: Checkout
await page.getByRole('button', { name: 'Checkout' }).click()
await expect(page).toHaveURL('/checkout')
// Step 5: Fill shipping info
await page.getByLabel('Full Name').fill('John Smith')
await page.getByLabel('Address').fill('123 Main Street')
await page.getByLabel('Phone').fill('555-123-4567')
// Step 6: Confirm order
await page.getByRole('button', { name: 'Confirm Order' }).click()
// Step 7: Success
await expect(page).toHaveURL(/\/order\//)
await expect(page.getByText('Order Successful')).toBeVisible()
})
})
Pattern 4: Responsive Test
Test on multiple viewports:
test.describe('Responsive Design', () => {
const viewports = [
{ name: 'mobile', width: 375, height: 667 },
{ name: 'tablet', width: 768, height: 1024 },
{ name: 'desktop', width: 1440, height: 900 },
]
for (const viewport of viewports) {
test(`should display correctly on ${viewport.name}`, async ({ page }) => {
await page.setViewportSize({
width: viewport.width,
heigh
Read the complete source ↗