Skip to content

Commit d58210d

Browse files
ademczukclaude
andcommitted
fix(test): resolve Feishu hoisted mock export syntax error
- Remove vi.hoisted() wrapper from exported mock in shared module (Vitest cannot export hoisted variables) - Inline vi.hoisted + vi.mock in startup test so Vitest's per-file hoisting registers mocks before production imports Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent c20ee11 commit d58210d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

extensions/feishu/src/monitor.startup.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
import type { ClawdbotConfig } from "openclaw/plugin-sdk";
22
import { afterEach, describe, expect, it, vi } from "vitest";
3+
4+
const probeFeishuMock = vi.hoisted(() => vi.fn());
5+
6+
vi.mock("./probe.js", () => ({
7+
probeFeishu: probeFeishuMock,
8+
}));
9+
10+
vi.mock("./client.js", () => ({
11+
createFeishuWSClient: vi.fn(() => ({ start: vi.fn() })),
12+
createEventDispatcher: vi.fn(() => ({ register: vi.fn() })),
13+
}));
14+
315
import { monitorFeishuProvider, stopFeishuMonitor } from "./monitor.js";
4-
import { probeFeishuMock } from "./monitor.test-mocks.js";
516

617
function buildMultiAccountWebsocketConfig(accountIds: string[]): ClawdbotConfig {
718
return {

extensions/feishu/src/monitor.test-mocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { vi } from "vitest";
22

3-
export const probeFeishuMock: ReturnType<typeof vi.fn> = vi.hoisted(() => vi.fn());
3+
export const probeFeishuMock: ReturnType<typeof vi.fn> = vi.fn();
44

55
vi.mock("./probe.js", () => ({
66
probeFeishu: probeFeishuMock,

0 commit comments

Comments
 (0)