fix(test): resolve Feishu hoisted mock export syntax error (#32128)

- 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 <noreply@anthropic.com>
This commit is contained in:
ademczuk 2026-03-03 01:34:16 +01:00 committed by GitHub
parent 1b5ac8b0b1
commit 53fd7f8163
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -1,7 +1,18 @@
import type { ClawdbotConfig } from "openclaw/plugin-sdk";
import { afterEach, describe, expect, it, vi } from "vitest";
const probeFeishuMock = vi.hoisted(() => vi.fn());
vi.mock("./probe.js", () => ({
probeFeishu: probeFeishuMock,
}));
vi.mock("./client.js", () => ({
createFeishuWSClient: vi.fn(() => ({ start: vi.fn() })),
createEventDispatcher: vi.fn(() => ({ register: vi.fn() })),
}));
import { monitorFeishuProvider, stopFeishuMonitor } from "./monitor.js";
import { probeFeishuMock } from "./monitor.test-mocks.js";
function buildMultiAccountWebsocketConfig(accountIds: string[]): ClawdbotConfig {
return {

View File

@ -1,6 +1,6 @@
import { vi } from "vitest";
export const probeFeishuMock: ReturnType<typeof vi.fn> = vi.hoisted(() => vi.fn());
export const probeFeishuMock: ReturnType<typeof vi.fn> = vi.fn();
vi.mock("./probe.js", () => ({
probeFeishu: probeFeishuMock,