mirror of
https://github.com/mattpocock/skills.git
synced 2026-07-30 03:22:34 +07:00
- Introduced TDD skills including deep modules, interface design, mocking, refactoring, and testing guidelines. - Added skills for breaking plans into GitHub issues and creating PRDs from conversation context. - Implemented productivity skills for scaffolding exercises, setting up pre-commit hooks, and managing notes in Obsidian. - Created a caveman communication mode for concise technical responses and a grilling technique for thorough plan discussions. - Developed a skill for writing new agent skills with structured templates and guidelines. - Included git guardrails to prevent dangerous git commands and a migration guide for using @total-typescript/shoehorn in tests.
32 lines
653 B
Markdown
32 lines
653 B
Markdown
# Interface Design for Testability
|
|
|
|
Good interfaces make testing natural:
|
|
|
|
1. **Accept dependencies, don't create them**
|
|
|
|
```typescript
|
|
// Testable
|
|
function processOrder(order, paymentGateway) {}
|
|
|
|
// Hard to test
|
|
function processOrder(order) {
|
|
const gateway = new StripeGateway();
|
|
}
|
|
```
|
|
|
|
2. **Return results, don't produce side effects**
|
|
|
|
```typescript
|
|
// Testable
|
|
function calculateDiscount(cart): Discount {}
|
|
|
|
// Hard to test
|
|
function applyDiscount(cart): void {
|
|
cart.total -= discount;
|
|
}
|
|
```
|
|
|
|
3. **Small surface area**
|
|
- Fewer methods = fewer tests needed
|
|
- Fewer params = simpler test setup
|