testing-mastery
Testing Mastery — Unified Testing Skill
Write tests that document intent, catch regressions, and run fast. Choose the right strategy for the right situation.
Decision Tree: Which Testing Strategy?
Is this a new feature?
├─ YES → Use TDD (see references/tdd-cycle.md)
│ Write failing test → Minimal code → Refactor
└─ NO
├─ Is this a bug fix?
│ └─ YES → Write regression test first, then fix
├─ Is this a critical user flow (login, checkout)?
│ └─ YES → E2E test (see references/e2e-playwright.md)
└─ Is this business logic / data transformation?
└─ YES → Unit + Integration tests (see references/unit-integration.md)
Testing Pyramid
/\ E2E (Few, ~10%)
/ \ Critical user flows only
/----\
/ \ Integration (Some, ~20%)
/--------\ API, DB, service contracts
/ \
/------------\ Unit (Many, ~70%)
Functions, classes, utilities
Core Principles
| Principle | Rule |
|---|---|
| AAA | Arrange → Act → Assert |
| Fast | Unit < 100ms, Integration < 1s |
| Isolated | No test depends on another |
| Behavior | Test WHAT, not HOW |
| Minimal | One assertion per test (ideally) |
Quick Reference
| I need to... | Use | Reference |
|---|---|---|
| Build feature test-first | TDD (RED-GREEN-REFACTOR) | tdd-cycle.md |
| Write unit/integration tests | Mocking, data strategies, patterns | unit-integration.md |
| Test critical user flows in browser | E2E with Playwright | e2e-playwright.md |
Anti-Patterns (Universal)
| ❌ Don't | ✅ Do |
|---|---|
| Test implementation details | Test observable behavior |
| Write tests after shipping | Write tests before/during |
| Duplicate test code | Use factories & fixtures |
| Complex test setup | Simplify or split |
| Ignore flaky tests | Fix root cause |
| Skip cleanup | Reset state in teardown |
| Multiple asserts per test | One behavior per test |
🔧 Runtime Scripts
| Script | Purpose | Command |
|---|---|---|
scripts/test_runner.py |
Unified test execution | python scripts/test_runner.py <project_path> |
scripts/playwright_runner.py |
Browser E2E testing | python scripts/playwright_runner.py <url> |
| With screenshot | python scripts/playwright_runner.py <url> --screenshot |
|
| Accessibility check | python scripts/playwright_runner.py <url> --a11y |
Remember: The test is the specification. If you can't write a test for it, you don't understand the requirement.
More from tai-ch0802/skills-bundle
sdd
Spec-Driven Development (SDD): A structured workflow (Requirement -> Analysis -> Implementation) enforcing explicit documentation before coding.
13code-quality
Pragmatic coding standards and code review guidelines. Covers naming, functions, anti-patterns, review checklists, and AI-specific review patterns. Replaces clean-code + code-review-checklist.
12prd
Guidelines and templates for creating effective Product Requirement Documents (PRD), bridging the gap between business goals and technical implementation.
8skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, update or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
8frontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
7seo-fundamentals
SEO 基礎、E-E-A-T、Core Web Vitals 和 Google 演算法原則。
7