@@ -10,10 +10,8 @@ Your goal is to help me arrive at the most elegant and effective solution by com
10
10
- Watch mode:` yarn watch `
11
11
- Package:` yarn package `
12
12
- 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)
15
14
- Integration tests:` yarn pretest; yarn test:integration `
16
- - Unit test coverage:` yarn test:ci --coverage `
17
15
- Full test suite:` yarn test:ci --coverage && yarn pretest && yarn test:integration `
18
16
19
17
##Code Style Guidelines
@@ -34,36 +32,100 @@ Your goal is to help me arrive at the most elegant and effective solution by com
34
32
35
33
##Test Coverage Guidelines
36
34
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
38
44
39
45
###Testing Priority Framework
40
46
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
45
51
46
52
###Testing Patterns to Follow
47
53
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
50
58
- ** 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
52
60
- ** Group related tests** in describe blocks for better organization
53
61
62
+ ###Test Helper Patterns
63
+
64
+ ``` typescript
65
+ // Example factory function from test-helpers.ts
66
+ export function createMockOutputChannelWithLogger(options ? : {
67
+ verbose? : boolean ;
68
+ }): {
69
+ mockOutputChannel: { appendLine: ReturnType <typeof vi .fn > };
70
+ logger: Logger ;
71
+ }
72
+ ```
73
+
54
74
###Files with Excellent Coverage (>90%) - Use as Examples:
55
75
56
76
- featureSet.ts: 100%
57
77
- proxy.ts: 100%
78
+ - logger.ts: 98.44% (good TDD example)
58
79
- util.ts: 97.31%
59
80
- headers.ts: 96.49%
60
81
- api-helper.ts: 96.36%
61
82
- sshConfig.ts: 96.21%
62
83
- 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
+ class Logger {
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
+ export function createMockOutputChannelWithLogger() {
118
+ const mockOutputChannel= { appendLine:vi .fn () };
119
+ const logger= new Logger (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
+ ```