tdd-workflow

Solid

Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.

AI & Automation 148,923 stars 23033 forks Updated 1 months ago MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
100
Recency 20%
75
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 測試驅動開發工作流程 此技能確保所有程式碼開發遵循 TDD 原則,並具有完整的測試覆蓋率。 ## 何時啟用 - 撰寫新功能或功能性程式碼 - 修復 Bug 或問題 - 重構現有程式碼 - 新增 API 端點 - 建立新元件 ## 核心原則 ### 1. 測試先於程式碼 總是先寫測試,然後實作程式碼使測試通過。 ### 2. 覆蓋率要求 - 最低 80% 覆蓋率(單元 + 整合 + E2E) - 涵蓋所有邊界案例 - 測試錯誤情境 - 驗證邊界條件 ### 3. 測試類型 #### 單元測試 - 個別函式和工具 - 元件邏輯 - 純函式 - 輔助函式和工具 #### 整合測試 - API 端點 - 資料庫操作 - 服務互動 - 外部 API 呼叫 #### E2E 測試(Playwright) - 關鍵使用者流程 - 完整工作流程 - 瀏覽器自動化 - UI 互動 ## TDD 工作流程步驟 ### 步驟 1:撰寫使用者旅程 ``` 身為 [角色],我想要 [動作],以便 [好處] 範例: 身為使用者,我想要語意搜尋市場, 以便即使沒有精確關鍵字也能找到相關市場。 ``` ### 步驟 2:產生測試案例 為每個使用者旅程建立完整的測試案例: ```typescript describe('Semantic Search', () => { it('returns relevant markets for query', async () => { // 測試實作 }) it('handles empty query gracefully', async () => { // 測試邊界案例 }) it('falls back to substring search when Redis unavailable', async () => { // 測試回退行為 }) it('sorts results by similarity score', async () => { // 測試排序邏輯 }) }) ``` ### 步驟 3:執行測試(應該失敗) ```bash npm test # 測試應該失敗 - 我們還沒實作 ``` ### 步驟 4:實作程式碼 撰寫最少的程式碼使測試通過: ```typescript // 由測試引導的實作 export async function searchMarkets(query: string) { // 實作在此 } ``` ### 步驟 5:再次執行測試 ```bash npm test # 測試現在應該通過 ``` ### 步驟 6:重構 在保持測試通過的同時改善程式碼品質: - 移除重複 - 改善命名 - 優化效能 - 增強可讀性 ### 步驟 7:驗證覆蓋率 ```bash npm run test:coverage # 驗證達到 80%+ 覆蓋率 ``` ## 測試模式 ### 單元測試模式(Jest/Vitest) ```typescript import { render, screen, fireEvent } from '@testing-library/react' import { Button } from './Button' describe('Button Component', () => { it('renders with correct te...

Details

Author
affaan-m
Repository
affaan-m/everything-claude-code
Created
4 months ago
Last Updated
1 months ago
Language
JavaScript
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Listed

tdd-workflow

在编写新功能、修复 bug 或重构代码时使用此 skill。强制执行测试驱动开发,覆盖率要求 80% 以上,包括单元测试、集成测试和 E2E 测试。

2 Updated today
aldo832
Testing & QA Listed

unit-test

Project-aware unit testing guide with mock patterns, TDD discipline, and best practices. Auto-detects test framework (Jest/Vitest) and provides appropriate examples. Use when: (1) writing or fixing unit tests, (2) user says "寫測試", "write test", "補測試", "add test", (3) user encounters mock patterns or test failures, (4) user asks how to test a composable, component, or store, (5) user says "mock imports", "test store", "怎麼測", "測試怎麼寫", (6) reviewing test quality: "unit test review", "review tests", "check test quality", "測試審查", "review 測試", "測試品質", "檢查測試品質", (7) TDD workflow: "TDD", "test driven", "紅綠燈", "先寫測試", "test first", "red green refactor".

4 Updated today
HsuanYuLee
AI & Automation Solid

test-driven-development

在实现任何功能或修复 bug 时使用,在编写实现代码之前

4,380 Updated 1 weeks ago
jnMetaCode
Testing & QA Listed

testing

Testing strategies and methodologies including TDD and E2E testing. Use when writing tests, implementing TDD workflow, or setting up E2E test infrastructure.

42 Updated 1 months ago
xiaobei930
Testing & QA Listed

test-driven-development

在实现任何功能或修复 bug 时使用,在编写实现代码之前

0 Updated 4 days ago
xjxj71