From 7b0fed3fb2b3136044416f09e159aaaf6bfb738a Mon Sep 17 00:00:00 2001 From: Aditya kumar singh <143548997+Adityakk9031@users.noreply.github.com> Date: Sun, 20 Sep 2026 03:28:11 +0530 Subject: [PATCH] fix(tools): resolve test type errors and stale module imports (#1545) --- packages/tools/test/claude-memory-examples.ts | 8 +++++--- .../tools/test/claude-memory-real-example.ts | 5 ++++- packages/tools/test/claude-memory.test.ts | 5 ++++- .../tools/test/mastra/integration.test.ts | 16 ++++++++++++++++ packages/tools/test/mastra/unit.test.ts | 19 +++++++++++++++++++ .../tools/test/openai-middleware.unit.test.ts | 9 ++++++--- packages/tools/test/test-memory-tool.ts | 8 +++++--- packages/tools/test/voltagent.unit.test.ts | 7 +++++-- .../tools/test/with-supermemory/unit.test.ts | 4 ++-- 9 files changed, 66 insertions(+), 15 deletions(-) diff --git a/packages/tools/test/claude-memory-examples.ts b/packages/tools/test/claude-memory-examples.ts index f37a47fa..4336f1e9 100644 --- a/packages/tools/test/claude-memory-examples.ts +++ b/packages/tools/test/claude-memory-examples.ts @@ -6,7 +6,10 @@ * 2. Anthropic SDK integration */ -import { createClaudeMemoryTool, type MemoryCommand } from "./claude-memory" +import { + createClaudeMemoryTool, + type MemoryCommand, +} from "../src/claude-memory" // ===================================================== // Example 1: Direct TypeScript/fetch Integration @@ -67,8 +70,7 @@ export async function directFetchExample() { ] // Execute each command - for (let i = 0; i < commands.length; i++) { - const command = commands[i] + for (const [i, command] of commands.entries()) { console.log( `\nšŸ“ Step ${i + 1}: ${command.command.toUpperCase()} ${command.path}`, ) diff --git a/packages/tools/test/claude-memory-real-example.ts b/packages/tools/test/claude-memory-real-example.ts index dbd03b21..1a925669 100644 --- a/packages/tools/test/claude-memory-real-example.ts +++ b/packages/tools/test/claude-memory-real-example.ts @@ -4,7 +4,10 @@ * This shows actual tool call handling based on real Claude API responses */ -import { createClaudeMemoryTool, type MemoryCommand } from "./claude-memory" +import { + createClaudeMemoryTool, + type MemoryCommand, +} from "../src/claude-memory" // ===================================================== // Real Claude API Integration diff --git a/packages/tools/test/claude-memory.test.ts b/packages/tools/test/claude-memory.test.ts index 97bccd90..6b8a25d7 100644 --- a/packages/tools/test/claude-memory.test.ts +++ b/packages/tools/test/claude-memory.test.ts @@ -1,5 +1,8 @@ import { describe, it, expect, beforeEach } from "vitest" -import { createClaudeMemoryTool, type MemoryCommand } from "./claude-memory" +import { + createClaudeMemoryTool, + type MemoryCommand, +} from "../src/claude-memory" import "dotenv/config" // Test configuration diff --git a/packages/tools/test/mastra/integration.test.ts b/packages/tools/test/mastra/integration.test.ts index cf6402a2..f58c6d49 100644 --- a/packages/tools/test/mastra/integration.test.ts +++ b/packages/tools/test/mastra/integration.test.ts @@ -121,6 +121,7 @@ describe.skipIf(!shouldRunIntegration)( messageList, abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processInput(args) @@ -153,6 +154,7 @@ describe.skipIf(!shouldRunIntegration)( messageList, abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processInput(args) @@ -192,6 +194,7 @@ describe.skipIf(!shouldRunIntegration)( messageList, abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processInput(args) @@ -234,6 +237,7 @@ describe.skipIf(!shouldRunIntegration)( messageList: createIntegrationMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processInput(args1) @@ -248,6 +252,7 @@ describe.skipIf(!shouldRunIntegration)( messageList: createIntegrationMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processInput(args2) @@ -283,6 +288,7 @@ describe.skipIf(!shouldRunIntegration)( messageList, abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processInput(args) @@ -314,6 +320,7 @@ describe.skipIf(!shouldRunIntegration)( messageList: createIntegrationMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processOutputResult(args) @@ -347,6 +354,7 @@ describe.skipIf(!shouldRunIntegration)( messageList: createIntegrationMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processOutputResult(args) @@ -385,6 +393,7 @@ describe.skipIf(!shouldRunIntegration)( abort: vi.fn() as never, retryCount: 0, requestContext, + state: {}, } await processor.processOutputResult(args) @@ -418,6 +427,7 @@ describe.skipIf(!shouldRunIntegration)( messageList, abort: vi.fn() as never, retryCount: 0, + state: {}, } await input.processInput(inputArgs) @@ -431,6 +441,7 @@ describe.skipIf(!shouldRunIntegration)( messageList: createIntegrationMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await output.processOutputResult(outputArgs) @@ -471,6 +482,7 @@ describe.skipIf(!shouldRunIntegration)( messageList, abort: vi.fn() as never, retryCount: 0, + state: {}, } await inputProcessor.processInput(args) @@ -535,6 +547,7 @@ describe.skipIf(!shouldRunIntegration)( messageList, abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processInput(args) @@ -559,6 +572,7 @@ describe.skipIf(!shouldRunIntegration)( messageList: createIntegrationMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processInput(args) @@ -593,6 +607,7 @@ describe.skipIf(!shouldRunIntegration)( messageList, abort: vi.fn() as never, retryCount: 0, + state: {}, } const result = await processor.processInput(args) @@ -617,6 +632,7 @@ describe.skipIf(!shouldRunIntegration)( messageList: createIntegrationMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await expect(processor.processOutputResult(args)).resolves.toBeDefined() diff --git a/packages/tools/test/mastra/unit.test.ts b/packages/tools/test/mastra/unit.test.ts index e4fd8263..9503299d 100644 --- a/packages/tools/test/mastra/unit.test.ts +++ b/packages/tools/test/mastra/unit.test.ts @@ -191,6 +191,7 @@ describe("SupermemoryInputProcessor", () => { messageList, abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processInput(args) @@ -227,6 +228,7 @@ describe("SupermemoryInputProcessor", () => { messageList: createMockMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processInput(args1) @@ -238,6 +240,7 @@ describe("SupermemoryInputProcessor", () => { messageList: createMockMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processInput(args2) @@ -270,6 +273,7 @@ describe("SupermemoryInputProcessor", () => { messageList: createMockMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processInput(args1) @@ -281,6 +285,7 @@ describe("SupermemoryInputProcessor", () => { messageList: createMockMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processInput(args2) @@ -302,6 +307,7 @@ describe("SupermemoryInputProcessor", () => { messageList, abort: vi.fn() as never, retryCount: 0, + state: {}, } const result = await processor.processInput(args) @@ -333,6 +339,7 @@ describe("SupermemoryInputProcessor", () => { messageList, abort: vi.fn() as never, retryCount: 0, + state: {}, } const result = await processor.processInput(args) @@ -360,6 +367,7 @@ describe("SupermemoryInputProcessor", () => { messageList: createMockMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processInput(args) @@ -390,6 +398,7 @@ describe("SupermemoryInputProcessor", () => { abort: vi.fn() as never, retryCount: 0, requestContext, + state: {}, } await processor.processInput(args) @@ -432,6 +441,7 @@ describe("SupermemoryInputProcessor", () => { messageList, abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processInput(args) @@ -499,6 +509,7 @@ describe("SupermemoryOutputProcessor", () => { messageList: createMockMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processOutputResult(args) @@ -539,6 +550,7 @@ describe("SupermemoryOutputProcessor", () => { messageList: createMockMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processOutputResult(args) @@ -567,6 +579,7 @@ describe("SupermemoryOutputProcessor", () => { messageList: createMockMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processOutputResult(args) @@ -603,6 +616,7 @@ describe("SupermemoryOutputProcessor", () => { abort: vi.fn() as never, retryCount: 0, requestContext, + state: {}, } await processor.processOutputResult(args) @@ -636,6 +650,7 @@ describe("SupermemoryOutputProcessor", () => { messageList: createMockMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processOutputResult(args) @@ -672,6 +687,7 @@ describe("SupermemoryOutputProcessor", () => { messageList: createMockMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processOutputResult(args) @@ -727,6 +743,7 @@ describe("SupermemoryOutputProcessor", () => { messageList: createMockMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processOutputResult(args) @@ -760,6 +777,7 @@ describe("SupermemoryOutputProcessor", () => { messageList: createMockMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } // Should not throw @@ -779,6 +797,7 @@ describe("SupermemoryOutputProcessor", () => { messageList: createMockMessageList(), abort: vi.fn() as never, retryCount: 0, + state: {}, } await processor.processOutputResult(args) diff --git a/packages/tools/test/openai-middleware.unit.test.ts b/packages/tools/test/openai-middleware.unit.test.ts index e3249c8d..ce04e1c0 100644 --- a/packages/tools/test/openai-middleware.unit.test.ts +++ b/packages/tools/test/openai-middleware.unit.test.ts @@ -26,7 +26,7 @@ describe("OpenAI middleware memory context", () => { }), }), ) - const originalCreate = vi.fn(() => + const originalCreate = vi.fn((_body?: unknown) => Object.assign(Promise.resolve({ choices: [] }), { asResponse: async () => new Response(), }), @@ -53,8 +53,11 @@ describe("OpenAI middleware memory context", () => { ], }) - const forwarded = originalCreate.mock.calls[0]?.[0] - const content = String(forwarded.messages[0].content) + const forwarded = originalCreate.mock.calls[0]?.[0] as + | { messages: Array<{ role: string; content: unknown }> } + | undefined + expect(forwarded).toBeDefined() + const content = String(forwarded?.messages[0]?.content) expect(content).toContain("Be helpful.") expect(content).toContain("Fresh profile fact") expect(content).not.toContain("Stale profile fact") diff --git a/packages/tools/test/test-memory-tool.ts b/packages/tools/test/test-memory-tool.ts index c0395a79..65bfaa1c 100644 --- a/packages/tools/test/test-memory-tool.ts +++ b/packages/tools/test/test-memory-tool.ts @@ -4,7 +4,10 @@ * Run with: bun run src/test-memory-tool.ts */ -import { createClaudeMemoryTool, type MemoryCommand } from "./claude-memory" +import { + createClaudeMemoryTool, + type MemoryCommand, +} from "../src/claude-memory" import "dotenv/config" async function testMemoryTool() { @@ -140,8 +143,7 @@ async function testMemoryTool() { let passed = 0 let failed = 0 - for (let i = 0; i < testCases.length; i++) { - const testCase = testCases[i] + for (const [i, testCase] of testCases.entries()) { console.log(`\\nšŸ”„ Test ${i + 1}/${testCases.length}: ${testCase.name}`) try { diff --git a/packages/tools/test/voltagent.unit.test.ts b/packages/tools/test/voltagent.unit.test.ts index 559f1fa1..4c9f8a8f 100644 --- a/packages/tools/test/voltagent.unit.test.ts +++ b/packages/tools/test/voltagent.unit.test.ts @@ -36,10 +36,13 @@ describe("VoltAgent memory context", () => { parts: [], }, ], - } as Parameters>[0] + } as unknown as Parameters>[0] const result = await hooks.onPrepareMessages?.(args) - const content = String(result?.messages?.[0]?.content ?? "") + const firstMessage = result?.messages?.[0] as + | Record + | undefined + const content = String(firstMessage?.content ?? "") expect(content).toContain("Be helpful.") expect(content).toContain("Fresh profile fact") expect(content).not.toContain("Stale profile fact") diff --git a/packages/tools/test/with-supermemory/unit.test.ts b/packages/tools/test/with-supermemory/unit.test.ts index 50900a6f..8c3d68af 100644 --- a/packages/tools/test/with-supermemory/unit.test.ts +++ b/packages/tools/test/with-supermemory/unit.test.ts @@ -561,8 +561,8 @@ describe("Unit: withSupermemory", () => { usage: { inputTokens: 1, outputTokens: 1, + totalTokens: 2, }, - rawCall: { rawPrompt: [], rawSettings: {} }, warnings: [], }) @@ -626,8 +626,8 @@ describe("Unit: withSupermemory", () => { usage: { inputTokens: 1, outputTokens: 1, + totalTokens: 2, }, - rawCall: { rawPrompt: [], rawSettings: {} }, warnings: [], })