mirror of
https://github.com/proffesor-for-testing/agentic-qe.git
synced 2026-09-19 08:45:47 +08:00
8ef84e382c
**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
4.8 KiB
4.8 KiB