Files
proffesor-for-testing__agen…/jest.setup.ts
Profa 8ef84e382c fix(mcp): add Database mock to fix test initialization errors
**Problem**: MCP tests failing with "this.database.initialize is not a function"
Error occurred when AgentRegistry creates MemoryManager in test environment

**Root Cause**:
1. Database mock existed in tests/__mocks__/Database.ts
2. Jest auto-discovery requires mocks in src/utils/__mocks__/ (adjacent to real module)
3. Without mock, real Database class instantiated but better-sqlite3 not available in test env

**Solution**:
1. Copied Database.ts mock to src/utils/__mocks__/Database.ts
2. Added jest.mock('./src/utils/Database') to jest.setup.ts for explicit activation
3. Mock provides all Database methods including initialize()

**Impact**: Eliminates database initialization errors in MCP test suite

**Mock Features**:
- Full better-sqlite3 API compatibility
- Synchronous and async method support
- Transaction support
- Domain-specific methods (upsertFleet, upsertAgent, etc.)
- Test helper (_resetMocks)

Fixes PR #25 CI test failures
2025-10-30 19:15:28 +00:00

4.8 KiB