Files
openclaw/src/agents/test-helpers/fast-tool-stubs.ts
2026-02-16 03:23:45 +01:00

31 lines
837 B
TypeScript

import { vi } from "vitest";
export type StubTool = {
name: string;
description: string;
parameters: { type: "object"; properties: Record<string, unknown> };
// Keep the exported type portable: don't leak Vitest's mock types into .d.ts.
execute: (...args: unknown[]) => unknown;
};
export const stubTool = (name: string): StubTool => ({
name,
description: `${name} stub`,
parameters: { type: "object", properties: {} },
execute: vi.fn() as unknown as (...args: unknown[]) => unknown,
});
vi.mock("../tools/image-tool.js", () => ({
createImageTool: () => stubTool("image"),
}));
vi.mock("../tools/web-tools.js", () => ({
createWebSearchTool: () => null,
createWebFetchTool: () => null,
}));
vi.mock("../../plugins/tools.js", () => ({
resolvePluginTools: () => [],
getPluginToolMeta: () => undefined,
}));