UNPKG

@debugmcp/mcp-debugger

Version:

Run-time step-through debugging for LLM agents.

104 lines (80 loc) 3.68 kB
# Task 4.1: Test Migration and Reorganization Progress ## Overview Successfully fixed critical test failures introduced by the adapter pattern refactoring. The main issue was that the Python adapter wasn't being registered properly due to validation failures during initialization. ## Key Fixes Implemented ### 1. Fixed DebugLanguage Enum Issue - **Problem**: Mock adapter was registered as 'javascript' but enum value didn't exist - **Solution**: Changed to use `DebugLanguage.MOCK` consistently - **File**: `src/container/dependencies.ts` ### 2. Fixed Python Adapter Registration - **Problem**: AdapterRegistry was validating adapters on registration, causing Python adapter to fail silently - **Solution**: Disabled `validateOnRegister` in production dependencies - **File**: `src/container/dependencies.ts` ```typescript const adapterRegistry = new AdapterRegistry({ validateOnRegister: false, // Validation happens when creating instances allowOverride: false }); ``` ### 3. Created Test Utilities - **Created**: `tests/test-utils/test-dependencies.ts` - Provides `createTestDependencies()` for consistent test setup - Supports options for including Python or Mock adapters - Creates all required mocks with proper interfaces - **Created**: `tests/test-utils/mock-logger.ts` - Provides `createMockLogger()` for consistent logger mocking - Includes spy logger variant for debugging ## Test Results ### Before Fix - E2E Tests: 4 failing - "Language 'python' is not supported. Available languages: javascript" - Many transport errors due to malformed JSON ### After Fix - E2E Tests: All passing ✓ - Both smoke tests now successfully create Python debug sessions ## Remaining Issues ### ProxyManager Logger Injection Still seeing failures in unit tests: ``` Cannot read properties of undefined (reading 'warn') ``` Need to ensure logger is properly injected in ProxyManager tests. ### Parameter Name Updates Many tests still use old parameter names: - `pythonPath``executablePath` - Missing `language` parameter ### Test Organization Tests are still scattered across various directories without clear separation between: - Core tests (adapter-agnostic) - Adapter-specific tests - Integration tests - E2E tests ## Next Steps 1. **Fix ProxyManager Tests** - Ensure logger is injected in all test setups - Update mock expectations 2. **Update Test Parameters** - Replace `pythonPath` with `executablePath` - Add `language` parameter to all session creations 3. **Reorganize Test Structure** ``` tests/ core/ # Tests using mock adapter only unit/ integration/ adapters/ # Language-specific tests python/ mock/ e2e/ # Full protocol tests test-utils/ # Shared utilities ``` 4. **Update Documentation** - Document new test structure - Provide running instructions for each category - Explain dependency requirements ## Lessons Learned 1. **Silent Failures**: The adapter registry was silently failing to register Python adapter due to validation 2. **Validation Timing**: Better to validate adapters when creating instances rather than during registration 3. **Test Utilities**: Having consistent test setup utilities is crucial for maintainability 4. **Adapter Pattern Impact**: The refactoring requires careful attention to initialization order and dependencies ## Conclusion The critical path for E2E tests is now working. The adapter pattern refactoring is solid, with both Mock and Python adapters properly registered and available. The remaining work is primarily test cleanup and organization rather than architectural fixes.