Skip to content

Commit 732b182

Browse files
committed
docs: enshrine testability as core development practice
Add comprehensive documentation and tooling to make testability the default way of working: Documentation: - TESTABILITY.md: Complete guide with principles, examples, checklists - FEATURE_TEMPLATE.md: Step-by-step template for new features - Updated CONTRIBUTING.md with testability section - PR template with testability checklist Key principles enshrined: 1. Extract pure functions to utils/ modules 2. 100% coverage on utilities 3. No non-null assertions (!) 4. Organize by domain, not "misc" 5. Atomic commits with clear dependencies Coverage targets: - Pure utilities: 100% - Integration: >80% - CLI/UI: >60% Scripts: - Added test:coverage command for easy coverage checks Real examples referenced: - Explorer subagent (99 tests, 100% utils coverage) - Repository indexer (87 tests, 100% utils coverage) This establishes testability as a first-class concern and provides clear guidance for all future development.
1 parent 202678a commit 732b182

File tree

5 files changed

+783
-6
lines changed

5 files changed

+783
-6
lines changed

.github/pull_request_template.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
## 📋 Description
2+
3+
<!-- Briefly describe what this PR does and why -->
4+
5+
## 🔗 Related Issues
6+
7+
<!-- Link to related GitHub issues -->
8+
Closes #
9+
10+
## 🧪 Testability Checklist
11+
12+
<!-- Check all that apply -->
13+
14+
- [ ] Pure functions extracted to `utils/` modules
15+
- [ ] Utilities achieve 100% coverage (statements & functions)
16+
- [ ] No `!` non-null assertions (use guard clauses or optional chaining)
17+
- [ ] Modules organized by domain (not generic "utils")
18+
- [ ] Each module < 200 lines
19+
- [ ] Atomic commits with clear dependencies
20+
21+
## ✅ Testing
22+
23+
<!-- Describe testing approach -->
24+
25+
- [ ] Unit tests added/updated
26+
- [ ] Integration tests added/updated
27+
- [ ] Coverage meets targets:
28+
- Pure utilities: 100%
29+
- Integration: >80%
30+
- CLI/UI: >60%
31+
- [ ] All tests passing locally
32+
33+
## 📊 Coverage
34+
35+
<!-- Paste coverage report for changed files -->
36+
37+
```
38+
Before: X% statements, Y% branches, Z% functions
39+
After: X% statements, Y% branches, Z% functions
40+
```
41+
42+
## 🏗️ Architecture
43+
44+
<!-- If refactoring, describe the structure -->
45+
46+
- [ ] Follows dependency order (foundation → dependent → integration)
47+
- [ ] Barrel exports for clean imports
48+
- [ ] Clear separation of pure/impure code
49+
50+
## 📝 Documentation
51+
52+
- [ ] Updated README if public API changed
53+
- [ ] Added JSDoc for public functions
54+
- [ ] Updated CHANGELOG (if applicable)
55+
56+
## 🚀 Deployment
57+
58+
- [ ] No breaking changes
59+
- [ ] Backward compatible
60+
- [ ] Database migrations (if applicable)
61+
62+
## 📸 Screenshots
63+
64+
<!-- If UI changes, add screenshots -->
65+
66+
---
67+
68+
**Commit Strategy:**
69+
<!-- Did you follow granular commits? -->
70+
- [ ] Atomic commits (each builds independently)
71+
- [ ] Conventional commit messages
72+
- [ ] Clear commit descriptions
73+

CONTRIBUTING.md

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
# Contributing to TS Monorepo
1+
# Contributing to Dev-Agent
22

3-
Thank you for considering contributing to our TypeScript monorepo! This document outlines the process for contributing and the standards we follow.
3+
Thank you for considering contributing to dev-agent! This document outlines the process for contributing and the standards we follow.
4+
5+
## 🎯 **Core Values**
6+
7+
1. **Testability First** - If it's hard to test, refactor it
8+
2. **Modularity** - Small, focused, reusable modules
9+
3. **100% Coverage on Utilities** - Pure functions should be fully tested
10+
4. **Atomic Commits** - Each commit should build and test independently
411

512
## Development Process
613

@@ -46,11 +53,56 @@ feat(core): add new API method for authentication
4653
3. Add the package to relevant workspace configurations.
4754
4. Update path mappings in the root `tsconfig.json`.
4855

49-
## Testing
56+
## Testing & Testability
57+
58+
### 📖 **Read First:** [TESTABILITY.md](./docs/TESTABILITY.md)
59+
60+
Our comprehensive testability guide covers:
61+
- When and how to extract utilities
62+
- Organization patterns
63+
- Coverage targets
64+
- Real-world examples
65+
66+
### **Quick Rules:**
67+
68+
1. **Extract Pure Functions** to `utils/` modules
69+
- ✅ DO: `utils/formatting.ts` with `formatDocument(doc: Document)`
70+
- ❌ DON'T: Private methods in 500-line classes
71+
72+
2. **Aim for 100% on Utilities**
73+
- Pure functions are easy to test
74+
- No mocks needed
75+
- Foundation for everything else
76+
77+
3. **No Non-Null Assertions (`!`)**
78+
- Use guard clauses or optional chaining
79+
- Makes code safer and more testable
80+
81+
4. **Organize by Domain**
82+
-`utils/strings.ts`, `utils/dates.ts`, `utils/validation.ts`
83+
-`utils.ts` (500 lines of everything)
84+
85+
### **Coverage Targets:**
86+
87+
| Code Type | Target | Example |
88+
|-----------|--------|---------|
89+
| **Pure Utilities** | 100% | `formatDocument()`, `calculateCoverage()` |
90+
| **Integration** | >80% | `RepositoryIndexer`, `ExplorerAgent` |
91+
| **CLI/UI** | >60% | Command handlers, spinners |
92+
93+
### **Before Submitting:**
94+
95+
```bash
96+
# Run tests with coverage
97+
pnpm vitest run --coverage
98+
99+
# Check specific package
100+
pnpm vitest run packages/core/src/indexer --coverage
101+
```
50102

51-
- Write tests for all new features and bug fixes.
52-
- Run existing tests to ensure your changes don't break existing functionality.
53-
- Aim for good test coverage.
103+
- Write tests for all new features and bug fixes
104+
- Run existing tests to ensure your changes don't break existing functionality
105+
- See [TESTABILITY.md](./docs/TESTABILITY.md) for detailed guidelines
54106

55107
## Code Style
56108

0 commit comments

Comments
 (0)