claude-code-best/tests/mocks/log.ts
James Feng 5b0c0fa46f fix: sync missing test mocks and agentToolFilter from upstream
Copied 6 missing mock files (auth, axios, childProcess, log, state,
toolContext) and agentToolFilter.ts from claude-code-best/claude-code.

Result: +92 tests pass, 9 'module not found' errors resolved.
LocalMemoryRecallTool has 40 new failures (mock/impl mismatch, TBD).
2026-06-02 00:59:36 +08:00

25 lines
843 B
TypeScript

/**
* Shared mock for src/utils/log.ts
*
* Cuts the bootstrap/state.ts dependency chain (module-level realpathSync + randomUUID).
* Must be called via mock.module("src/utils/log.ts", logMock) BEFORE any import that
* transitively depends on log.ts.
*
* Exported as a factory so each call produces a fresh object (mock.module requirement).
*/
export function logMock() {
return {
logError: () => {},
getLogDisplayTitle: () => '',
dateToFilename: (d: Date) => d.toISOString().replace(/[:.]/g, '-'),
attachErrorLogSink: () => {},
getInMemoryErrors: () => [] as Array<{ error: string; timestamp: string }>,
loadErrorLogs: async () => [],
getErrorLogByIndex: async () => null,
logMCPError: () => {},
logMCPDebug: () => {},
captureAPIRequest: () => {},
_resetErrorLogForTesting: () => {},
}
}