coverage
alirezarezvani/claude-skills
分析測試覆蓋率缺口。 當使用者提及「測試覆蓋率」、「哪些部分未經測試」、「覆蓋率缺口」、「缺失的測試」、「覆蓋率報告」或「哪些部分需要測試」時,請使用此術語。
...展開全部關於coverage
此技能可分析應用程式中的測試coverage 缺口,重點在於端到端/Playwright 測試。 它透過映射所有可測試的範圍(路由、元件、API 端點及關鍵使用者流程),並將其與現有測試進行比對,從而解決「無法確知實際測試範圍」的問題,讓團隊能清楚掌握其coverage 的薄弱環節。
此工作流程透過「探索」(Explore)子代理程式,將路由與頁面(Next.js 應用程式目錄、React Router、Vue Router 等)、互動式元件及 API 端點進行目錄化,接著掃描現有的 `*.spec.ts`/`*.spec.js` 檔案,以判定哪些頁面、元件和端點已被測試。 它會產生一個包含「已覆蓋/部分覆蓋/未覆蓋」狀態的coverage 矩陣表,依據業務影響程度(關鍵、高、中、低)對未覆蓋的領域進行優先級排序,並建議具體的測試計畫,其中包含所需的測試數量、推薦的範本以及工作量估算。 使用者可選擇透過執行配套的 `/pw:generate` 指令,自動為最關鍵的缺口生成測試。
本工具主要針對使用 Playwright 的品質保證工程師與開發人員,他們希望獲得結構化且已依優先級排序的「coverage 」檢視,而非單純的百分比數據。它會讀取原始碼和測試檔案,並能觸發測試生成,但其自身的分析僅為對程式碼庫的唯讀檢查,並據此產生報告與建議。
常見問題
這項工具的功能是什麼?
它會繪製應用程式的路由、元件、API 端點及使用者流程,並將其與現有測試進行比對,進而產生一份按優先級排序的「coverage 」矩陣及測試計畫。
它基於哪種測試框架建構?
Playwright 端到端測試;它會掃描 *.spec.ts / *.spec.js 檔案,並與配套的 /pw:generate 指令整合。
它是如何為缺口設定優先順序的?
依據業務影響程度:優先處理身分驗證和支付等關鍵領域,接著是面向使用者的 CRUD 操作與導覽功能,再者是設定選項與邊緣案例,最後才是價值較低的靜態頁面。
它能自動編寫缺失的測試嗎?
可選功能。在報告缺口後,系統會詢問是否要為前 N 個缺口生成測試,並使用推薦的範本呼叫 /pw:generate 指令。
分析過程中會修改程式碼嗎?
coverage 的分析過程本身為唯讀模式;它會檢查路由定義、元件及規格檔案。測試產生是一個獨立的、需主動啟用的步驟。
Map all testable surfaces in the application and identify what's tested vs. what's missing.
Steps
1. Map Application Surface
Use the Explore subagent to catalog:
Routes/Pages:
- Scan route definitions (Next.js
app/, React Router config, Vue Router, etc.) - List all user-facing pages with their paths
Components:
- Identify interactive components (forms, modals, dropdowns, tables)
- Note components with complex state logic
API Endpoints:
- Scan API route files or backend controllers
- List all endpoints with their methods
User Flows:
- Identify critical paths: auth, checkout, onboarding, core features
- Map multi-step workflows
2. Map Existing Tests
Scan all *.spec.ts / *.spec.js files:
- Extract which pages/routes are covered (by
page.goto()calls) - Extract which components are tested (by locator usage)
- Extract which API endpoints are mocked or hit
- Count tests per area
3. Generate Coverage Matrix
## Coverage Matrix| Area | Route | Tests | Status ||---|---|---|---|| Auth | /login | 5 | ✅ Covered || Auth | /register | 0 | ❌ Missing || Auth | /forgot-password | 0 | ❌ Missing || Dashboard | /dashboard | 3 | ⚠️ Partial (no error states) || Settings | /settings | 0 | ❌ Missing || Checkout | /checkout | 8 | ✅ Covered |4. Prioritize Gaps
Rank uncovered areas by business impact:
- Critical — auth, payment, core features → test first
- High — user-facing CRUD, search, navigation
- Medium — settings, preferences, edge cases
- Low — static pages, about, terms
5. Suggest Test Plan
For each gap, recommend:
- Number of tests needed
- Which template from
templates/to use - Estimated effort (quick/medium/complex)
## Recommended Test Plan### Priority 1: Critical1. /register (4 tests) — use auth/registration template — quick2. /forgot-password (3 tests) — use auth/password-reset template — quick### Priority 2: High3. /settings (4 tests) — use settings/ templates — medium4. Dashboard error states (2 tests) — use dashboard/data-loading template — quick6. Auto-Generate (Optional)
Ask user: "Generate tests for the top N gaps? [Yes/No/Pick specific]"
If yes, invoke /pw:generate for each gap with the recommended template.
Output
- Coverage matrix (table format)
- Coverage percentage estimate
- Prioritized gap list with effort estimates
- Option to auto-generate missing tests
安裝 coverage
請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。
下載 ZIP複製儲存庫並將技能檔案複製到您的專案中。
git clone https://github.com/alirezarezvani/claude-skills/blob/main/engineering-team/playwright-pro/skills/coverage/SKILL.md # Copy SKILL.md to your .claude/skills/ directory
複製





首頁
