Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8021706

Browse files
jaggederestclaude
andcommitted
docs: update CLAUDE.md with TDD patterns and techniques from session
- Update coverage stats: 74.35% with 359 unit tests- Add TDD approach section emphasizing test-first development- Include factory function pattern with createMockOutputChannelWithLogger example- Add refactoring strategy with backward compatibility pattern- Emphasize ALWAYS using yarn test:ci --coverage (not individual files)- Include concrete Logger integration example showing the full pattern- Update high-coverage files to include logger.ts (98.44%) as TDD example🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
1 parent97ff5fb commit8021706

File tree

1 file changed

+80
-18
lines changed

1 file changed

+80
-18
lines changed

‎CLAUDE.md

Lines changed: 80 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ Your goal is to help me arrive at the most elegant and effective solution by com
1010
- Watch mode:`yarn watch`
1111
- Package:`yarn package`
1212
- Lint with auto-fix:`yarn lint:fix` (always use this instead of regular lint)
13-
- Run all unit tests:`yarn test:ci`
14-
- Run specific unit test:`yarn test:ci` (always use this instead of vitest directly)
13+
-**Run all unit tests with coverage:`yarn test:ci --coverage`** (ALWAYS use this, not individual file testing)
1514
- Integration tests:`yarn pretest; yarn test:integration`
16-
- Unit test coverage:`yarn test:ci --coverage`
1715
- Full test suite:`yarn test:ci --coverage && yarn pretest && yarn test:integration`
1816

1917
##Code Style Guidelines
@@ -34,36 +32,100 @@ Your goal is to help me arrive at the most elegant and effective solution by com
3432

3533
##Test Coverage Guidelines
3634

37-
Current status:**48.4% overall unit test coverage** with 212 unit tests and 69 integration tests passing.
35+
Current status:**74.35% overall unit test coverage** with 359 unit tests and 69 integration tests passing.
36+
37+
###TDD Approach for New Features
38+
39+
1.**Write failing test first** - define expected behavior
40+
2.**Implement minimal code** to make test pass
41+
3.**Run full test suite** with`yarn test:ci --coverage`
42+
4.**Refactor if needed** while keeping tests green
43+
5.**Ensure backward compatibility** when modifying existing interfaces
3844

3945
###Testing Priority Framework
4046

41-
1.**Files with <50% coverage** need immediate attention (remote.ts:8.84%,commands.ts:21.09%)
42-
2.**Add incremental tests** - focus on1-3 tests per session to see measurable progress
43-
3.**Target coverage improvements** of 5-15 percentage points per file per session
44-
4.**Always run coverage after changes** to measure progress:`yarn test:ci --coverage`
47+
1.**Files with <50% coverage** need immediate attention (remote.ts:49.21%,extension.ts:38.68%)
48+
2.**Add incremental tests** - focus onmeasurable progress each session
49+
3.**Target coverage improvements** of 5-15 percentage points per file
50+
4.**ALWAYS use`yarn test:ci --coverage`** - never test individual files
4551

4652
###Testing Patterns to Follow
4753

48-
-**Mock external dependencies** properly using vi.mock() and proper TypeScript types
49-
-**Create reusable mock types** instead of using`any` or eslint-disable
54+
-**Create factory functions** for common test setups (see test-helpers.ts)
55+
-**Use createMockOutputChannelWithLogger()** for consistent Logger testing
56+
-**Avoid`as any`** - create proper mock types or use`as never` for VS Code mocks
57+
-**Mock external dependencies** properly using vi.mock() with TypeScript types
5058
-**Test core functionality first** - constructor, main methods, error paths
51-
-**Use descriptive test names**that explain the specific behavior being tested
59+
-**Ensure backward compatibility**by adding compatibility methods during refactoring
5260
-**Group related tests** in describe blocks for better organization
5361

62+
###Test Helper Patterns
63+
64+
```typescript
65+
// Example factory function from test-helpers.ts
66+
exportfunction createMockOutputChannelWithLogger(options?: {
67+
verbose?:boolean;
68+
}): {
69+
mockOutputChannel: { appendLine:ReturnType<typeofvi.fn> };
70+
logger:Logger;
71+
}
72+
```
73+
5474
###Files with Excellent Coverage (>90%) - Use as Examples:
5575

5676
- featureSet.ts: 100%
5777
- proxy.ts: 100%
78+
- logger.ts: 98.44% (good TDD example)
5879
- util.ts: 97.31%
5980
- headers.ts: 96.49%
6081
- api-helper.ts: 96.36%
6182
- sshConfig.ts: 96.21%
6283
- api.ts: 95.52%
63-
64-
###Current Testing Approach
65-
66-
-**No production code changes** during testing phase
67-
-**Incremental improvements** - systematically work through files by coverage priority
68-
-**Comprehensive mocking** for VS Code API, external dependencies, and internal modules
69-
-**Both positive and negative test cases** for robust coverage
84+
- error.ts: 90.44%
85+
86+
###Current Development Approach
87+
88+
-**TDD for new features** - test first, implement second
89+
-**Incremental refactoring** - small, measurable improvements
90+
-**Backward compatibility** - add compatibility methods when changing interfaces
91+
-**Factory functions in test-helpers.ts** - reusable test setup patterns
92+
-**Systematic cleanup** - remove`as any` casts, add proper types
93+
-**Measure progress constantly** - run`yarn test:ci --coverage` after every change
94+
95+
###Refactoring Strategy
96+
97+
When replacing legacy patterns (e.g., writeToCoderOutputChannel):
98+
1. Add backward compatibility method to new implementation
99+
2. Write tests verifying compatibility
100+
3. Incrementally replace usage starting with highest-impact files
101+
4. Maintain full test suite passing throughout
102+
103+
###Example: Logger Integration Pattern
104+
105+
```typescript
106+
// 1. Add backward compatibility to new class
107+
classLogger {
108+
// ... new methods ...
109+
110+
// Backward compatibility for legacy code
111+
writeToCoderOutputChannel(message:string):void {
112+
this.info(message);
113+
}
114+
}
115+
116+
// 2. Create factory in test-helpers.ts
117+
exportfunction createMockOutputChannelWithLogger() {
118+
const mockOutputChannel= { appendLine:vi.fn() };
119+
const logger=newLogger(mockOutputChannel);
120+
return {mockOutputChannel,logger };
121+
}
122+
123+
// 3. Test compatibility before refactoring
124+
it("should be backward compatible", ()=> {
125+
const { mockOutputChannel, logger }=createMockOutputChannelWithLogger();
126+
logger.writeToCoderOutputChannel("Test");
127+
expect(mockOutputChannel.appendLine).toHaveBeenCalledWith(
128+
expect.stringMatching(/\[.*\]\[INFO\] Test/)
129+
);
130+
});
131+
```

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp