You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- 🔸 **Data validation** - invalid inputs, type mismatches
312
312
313
313
#### Real-World Scenarios
314
314
315
-
-✅ **Fresh install** - clean slate
316
-
-✅ **Existing user** - migration scenarios
317
-
-✅ **Power user** - complex configurations
318
-
-🔸 **Error recovery** - graceful degradation
315
+
- ✅ **Fresh install** - clean slate
316
+
- ✅ **Existing user** - migration scenarios
317
+
- ✅ **Power user** - complex configurations
318
+
- 🔸 **Error recovery** - graceful degradation
319
319
320
320
### Example Test Plan Structure
321
321
@@ -324,30 +324,30 @@ function generateTestScenarios(analysis: FunctionAnalysis): TestScenario[] {
324
324
325
325
### 1. Configuration Migration Tests
326
326
327
-
-No legacy settings exist
328
-
-Legacy settings already migrated
329
-
-Fresh migration needed
330
-
-Partial migration required
331
-
-Migration failures
327
+
- No legacy settings exist
328
+
- Legacy settings already migrated
329
+
- Fresh migration needed
330
+
- Partial migration required
331
+
- Migration failures
332
332
333
333
### 2. Configuration Source Tests
334
334
335
-
-Global search paths
336
-
-Workspace search paths
337
-
-Settings precedence
338
-
-Configuration errors
335
+
- Global search paths
336
+
- Workspace search paths
337
+
- Settings precedence
338
+
- Configuration errors
339
339
340
340
### 3. Path Resolution Tests
341
341
342
-
-Absolute vs relative paths
343
-
-Workspace folder resolution
344
-
-Path validation and filtering
342
+
- Absolute vs relative paths
343
+
- Workspace folder resolution
344
+
- Path validation and filtering
345
345
346
346
### 4. Integration Scenarios
347
347
348
-
-Combined configurations
349
-
-Deduplication logic
350
-
-Error handling flows
348
+
- Combined configurations
349
+
- Deduplication logic
350
+
- Error handling flows
351
351
```
352
352
353
353
## 🔧 Step 4: Set Up Your Test Infrastructure
@@ -514,47 +514,47 @@ envConfig.inspect
514
514
515
515
### Configuration Tests
516
516
517
-
-Test different setting combinations
518
-
-Test setting precedence (workspace > user > default)
519
-
-Test configuration errors and recovery
520
-
-Always use dynamic path construction with Node.js `path` module when testing functions that resolve paths against workspace folders to ensure cross-platform compatibility
517
+
- Test different setting combinations
518
+
- Test setting precedence (workspace > user > default)
519
+
- Test configuration errors and recovery
520
+
- Always use dynamic path construction with Node.js `path` module when testing functions that resolve paths against workspace folders to ensure cross-platform compatibility
-[ ]**Fast execution** - tests run quickly with proper mocking
550
550
551
551
### Common Anti-Patterns to Avoid
552
552
553
-
-❌ Testing implementation details instead of behavior
554
-
-❌ Brittle assertions that break on cosmetic changes
555
-
-❌ Order-dependent tests that fail due to processing changes
556
-
-❌ Tests that don't clean up mocks properly
557
-
-❌ Overly complex test setup that's hard to understand
553
+
- ❌ Testing implementation details instead of behavior
554
+
- ❌ Brittle assertions that break on cosmetic changes
555
+
- ❌ Order-dependent tests that fail due to processing changes
556
+
- ❌ Tests that don't clean up mocks properly
557
+
- ❌ Overly complex test setup that's hard to understand
558
558
559
559
## 🔄 Reviewing and Improving Existing Tests
560
560
@@ -567,13 +567,14 @@ envConfig.inspect
567
567
568
568
### Common Fixes
569
569
570
-
-Over-complex mocks → Minimal mocks with only needed methods
571
-
-Brittle assertions → Behavior-focused with error messages
572
-
-Vague test names → Clear scenario descriptions (transform "should return X when Y" into "should [expected behavior] when [scenario context]")
573
-
-Missing structure → Mock → Run → Assert pattern
574
-
-Untestable Node.js APIs → Create proxy abstraction functions (use function overloads to preserve intelligent typing while making functions mockable)
570
+
- Over-complex mocks → Minimal mocks with only needed methods
571
+
- Brittle assertions → Behavior-focused with error messages
572
+
- Vague test names → Clear scenario descriptions (transform "should return X when Y" into "should [expected behavior] when [scenario context]")
573
+
- Missing structure → Mock → Run → Assert pattern
574
+
- Untestable Node.js APIs → Create proxy abstraction functions (use function overloads to preserve intelligent typing while making functions mockable)
575
575
576
576
## 🧠 Agent Learnings
577
-
- Avoid testing exact error messages or log output - assert only that errors are thrown or rejection occurs to prevent brittle tests (1)
578
-
- Create shared mock helpers (e.g., `createMockLogOutputChannel()`) instead of duplicating mock setup across multiple test files (1)
579
577
578
+
- Avoid testing exact error messages or log output - assert only that errors are thrown or rejection occurs to prevent brittle tests (1)
579
+
- Create shared mock helpers (e.g., `createMockLogOutputChannel()`) instead of duplicating mock setup across multiple test files (1)
580
+
- Use `sinon.useFakeTimers()` with `clock.tickAsync()` instead of `await new Promise(resolve => setTimeout(resolve, ms))` for debounce/timeout handling - eliminates flakiness and speeds up tests significantly (1)
0 commit comments