Anti-Pattern 3: Mocking Without Understanding
**The violation:** ```typescript // ❌ BAD: Mock breaks test logic test('detects duplicate server', () => { // Mock prevents config write that test depends on! vi.mock('ToolCatalog', () => ({ discoverAndCacheTools: vi.fn().mockResolvedValue(undefined) })); await addServer(config); await addServer(config); // Should throw - but won't! }); ``` **Why this is wrong:** - Mocked method had side effect test depended on (writing config) - Over-mocking to "be safe" breaks actual behavior - Test passes for wrong reason or fails mysteriously **The fix:** ```typescript // ✅ GOOD: Mock at correct level test('detects duplicate server', () => { // Mock the slow part, preserve behavior test needs vi.mock('MCPServerManager'); // Just mock slow server startup await addServer(config); // Config written await addServer(config); // Duplicate detected ✓ }); ```