mit einem Klick
test-generator
Generate test files for new code including unit, integration, and e2e tests. Triggers: test, 產生測試, generate test, 測試, 寫測試.
Menü
Generate test files for new code including unit, integration, and e2e tests. Triggers: test, 產生測試, generate test, 測試, 寫測試.
Audit and auto-update skills, hooks, instructions, and bylaws to stay in sync with codebase changes. Triggers: self-update, 自主更新, audit skills, 審計技能, update instructions, 更新指令, sync hooks, 同步 hooks.
Assist with Frontend DDD architecture design, component organization, and testing. Triggers: frontend, 前端, react, component, 元件, vitest.
Automatically update CHANGELOG.md based on code changes following Keep a Changelog format. Triggers: changelog, 更新 changelog, update changelog, 變更紀錄.
Proactively suggest and execute code refactoring to maintain clean architecture. Triggers: refactor, 重構, 優化程式碼, clean up, 整理程式碼.
Perform code review with DDD architecture compliance check. Triggers: review, 程式碼審查, code review, 審查, CR.
Assist with DDD architecture design and compliance checking. Triggers: DDD, 架構, architecture, 領域設計, domain design.
| name | test-generator |
| description | Generate test files for new code including unit, integration, and e2e tests. Triggers: test, 產生測試, generate test, 測試, 寫測試. |
為新程式碼自動產生測試檔案,支援 Python (pytest) 和 TypeScript/React (Vitest + RTL)。
tests/unit/tests/integration/tests/e2e/test_{module_name}.py
└─ test_{function_name}_{scenario}
└─ test_{function_name}_when_{condition}
# 執行所有測試
uv run pytest
# 執行特定測試
uv run pytest tests/unit/test_phi_types.py -v
依據子法:
.github/bylaws/frontend-ddd.md第 4 條
| 類型 | 框架 | 用途 |
|---|---|---|
| 單元測試 | Vitest | 純函數、Hooks |
| 元件測試 | React Testing Library | UI 互動 |
| E2E 測試 | Playwright | 完整流程 |
web/frontend/
├── src/**/*.test.ts # 元件旁測試(推薦)
└── tests/
├── unit/ # domain 層測試
├── integration/ # application 層測試
└── e2e/ # 端到端測試
{ComponentName}.test.tsx
└─ describe('{ComponentName}')
└─ it('should {expected behavior}')
└─ it('should {behavior} when {condition}')
// TasksPanel.test.tsx
import { render, screen } from '@testing-library/react';
import { TasksPanel } from './TasksPanel';
describe('TasksPanel', () => {
it('should render task list', () => {
render(<TasksPanel />);
expect(screen.getByRole('list')).toBeInTheDocument();
});
it('should show empty state when no tasks', () => {
render(<TasksPanel tasks={[]} />);
expect(screen.getByText(/no tasks/i)).toBeInTheDocument();
});
});
cd web/frontend
# 執行所有測試
npm run test
# 監聽模式
npm run test:watch
# 覆蓋率報告
npm run test:coverage
# E2E 測試
npm run test:e2e
| 層級 | 最低覆蓋率 |
|---|---|
| domain | 90% |
| application | 80% |
| presentation | 70% |
| infrastructure | 60% |
🧪 測試生成
目標:core/domain/phi_types.py
產生的測試檔案:
✅ tests/unit/test_phi_types.py
└─ test_phi_type_validation
└─ test_phi_type_from_string
└─ test_phi_type_invalid_input
✅ tests/integration/test_phi_detection.py
└─ test_detect_phi_in_text
└─ test_detect_multiple_phi_types
測試覆蓋率預估:85%
下一步:執行 `uv run pytest tests/unit/test_phi_types.py -v`
🧪 測試生成
目標:web/frontend/src/presentation/components/TasksPanel.tsx
產生的測試檔案:
✅ TasksPanel.test.tsx (元件旁測試)
└─ should render task list
└─ should show loading state
└─ should handle task click
✅ tests/integration/useTasks.test.ts
└─ should fetch tasks on mount
└─ should handle API errors
測試覆蓋率預估:75%
下一步:執行 `cd web/frontend && npm run test`