Logo Test Engineer

Test Engineer

Cộng đồng
wasintoh
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.

Add to TypingMind

Tổng quan

Nhà phát hànhwasintoh
Kho mãtoh-framework
Tên kỹ năngtest-engineer
Sao
96
Bản fork
19
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Hướng dẫn có đủ mọi thứ cần thiết

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được wasintoh công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Test Engineer trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/wasintoh/toh-framework/tree/main/src/skills/test-engineer
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wasintoh/toh-framework.git /tmp/toh-framework
mkdir -p .claude/skills
cp -r /tmp/toh-framework/src/skills/test-engineer .claude/skills/test-engineer
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Test Engineer trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Test Engineer ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Test Engineer với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

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"

  1. Auto-Generate Tests - Generate test cases from UI automatically
  2. Auto-Fix Loop - If fails, fix and re-test until passing
  3. Human-Readable Reports - Easy to understand reports
  4. Language-Adaptive - Error messages adapt to project language setting

Tech Stack

ToolPurpose
PlaywrightE2E Testing
@playwright/testTest Runner
playwright-reportHTML Reports

Setup

1. Install Playwright

bash
npm install -D @playwright/test
npx playwright install

2. Config File

Create playwright.config.ts:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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, 
        height: viewport.height 
      })
      
      await page.goto('/products')
      
      // Check layout adapts
      if (viewport.name === 'mobile') {
        await expect(page.getByTestId('mobile-menu')).toBeVisible()
        await expect(page.getByTestId('desktop-nav')).not.toBeVisible()
      } else {
        await expect(page.getByTestId('desktop-nav')).toBeVisible()
      }
      
      // Screenshot for visual comparison
      await page.screenshot({ 
        path: `screenshots/products-${viewport.name}.png`,
        fullPage: true 
      })
    })
  }
})

Auto-Fix Loop Strategy

Loop Flow

┌─────────────────────────────────────────────────────┐
│  Run Tests                                          │
└─────────────────────────────────────────────────────┘
                        │
            ┌───────────┴───────────┐
            │                       │
            ▼                       ▼
      ┌──────────┐           ┌──────────┐
      │  PASS ✅ │           │  FAIL ❌ │
      └──────────┘           └──────────┘
            │                       │
            ▼                       ▼
      ┌──────────┐           ┌──────────────────┐
      │  Done!   │           │  Analyze Error   │
      └──────────┘           └──────────────────┘
                                    │
                                    ▼
                            ┌──────────────────┐
                            │  Call /toh-fix   │
                            └──────────────────┘
                                    │
                                    ▼
                            ┌──────────────────┐
                            │  Re-run Tests    │
                            │  (max 3 loops)   │
                            └──────────────────┘
                                    │
                                    ▼
                            ┌──────────────────┐
                            │  Still failing?  │
                            └──────────────────┘
                                    │
                    ┌───────────────┴───────────────┐
                    │                               │
                    ▼                               ▼
              ┌──────────┐                   ┌──────────────┐
              │  PASS ✅ │                   │  Report to   │
              └──────────┘                   │  Human 🧑‍💻    │
                                             └──────────────┘

Error Analysis Matrix

Error PatternRoot CauseAuto-Fix Strategy
strict mode violationMultiple elements match selectorUse more specific selector
Timeout waiting for selectorElement doesn't appearAdd wait or check condition
expect.toBeVisible failedElement hidden/not renderedCheck state/condition
Navigation timeoutPage loads slowlyIncrease timeout or optimize
net::ERR_CONNECTION_REFUSEDServer not startedCheck webServer config
Element is not clickableElement is overlaidScroll into view or wait

Fix Context Template

When calling /toh-fix, send this context:

markdown
## Test Failure Report

**File:** tests/login.spec.ts
**Test:** should login successfully
**Line:** 25

### Error Message

Error: locator.click: Error: strict mode violation: getByRole('button', { name: 'Login' }) resolved to 2 elements


### Code Context
```typescript
// Line 23-27
await page.getByLabel('Password').fill('password123')
await page.getByRole('button', { name: 'Login' }).click() // ← Error here
await expect(page).toHaveURL('/dashboard')

Screenshot

failure

Suggested Fixes

  1. Use getByRole('button', { name: 'Login', exact: true })
  2. Use getByTestId('login-submit-button')
  3. Use .first() or .nth(0)

## Report Format

### Console Output (Short & Concise)

🧪 Running tests...

✓ auth/login.spec.ts (3 tests) - 2.1s ✓ auth/register.spec.ts (4 tests) - 3.2s ✗ products/list.spec.ts (5 tests) - 4.5s └── ❌ should filter by category (attempt 1/3) 🔧 Auto-fixing... └── ✓ Fixed! Re-running... └── ✓ should filter by category (passed) ✓ checkout/flow.spec.ts (2 tests) - 5.1s

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✅ All tests passed! Total: 14 | Passed: 14 | Fixed: 1 Duration: 15.2s ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━


### Full Report (HTML)

Generate HTML report at:
- `playwright-report/index.html`

View with:
```bash
npx playwright show-report

Best Practices

1. Use data-testid

Add data-testid to important elements:

tsx
// ✅ Good
<button data-testid="submit-order">Order Now</button>

// ❌ Bad - text might change
<button>Order Now</button>

2. Wait for Network Idle

For pages that load data:

typescript
await page.goto('/products', { waitUntil: 'networkidle' })

3. Use Locator Assertions

typescript
// ✅ Good - Auto-retry
await expect(page.getByText('Success')).toBeVisible()

// ❌ Bad - No retry
const text = await page.textContent('.message')
expect(text).toBe('Success')

4. Group Related Tests

typescript
test.describe('Product Management', () => {
  test.describe('Create', () => {
    test('should create new product', ...)
    test('should validate required fields', ...)
  })
  
  test.describe('Edit', () => {
    test('should edit existing product', ...)
  })
  
  test.describe('Delete', () => {
    test('should delete product', ...)
    test('should confirm before delete', ...)
  })
})

5. Use Fixtures for Test Data

typescript
// tests/fixtures/test-data.ts
export const testUser = {
  email: 'test@example.com',
  password: 'TestPassword123!',
  name: 'Test User',
}

export const testProduct = {
  name: 'Drip Coffee',
  price: 4.50,
  category: 'Beverages',
}

Integration Commands

bash
# Run all tests
/toh-test

# Run specific file
/toh-test auth/login

# Run with UI mode (debug)
/toh-test --debug

# Update snapshots
/toh-test --update-snapshots

# Run on CI
/toh-test --ci

MCP Integration

Use Playwright MCP for:

  • Browser automation
  • Screenshot capture
  • Network interception
  • Console log capture
typescript
// Example: Using Playwright MCP
const browser = await playwright.chromium.launch()
const page = await browser.newPage()

// MCP handles the rest...

Câu hỏi thường gặp

Kỹ năng AI Test Engineer làm được gì?

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.

Vì sao nên dùng Test Engineer trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Test Engineer là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Test Engineer trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/wasintoh/toh-framework/tree/main/src/skills/test-engineer. TypingMind đọc tệp SKILL.md rồi cài đặt kỹ năng để bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Test Engineer?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Test Engineer với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Test Engineer với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Test Engineer có miễn phí không?

Có. Kỹ năng này được wasintoh phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇