mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-02 02:57:51 +00:00
test(core): reduce mock reset overhead across unit and e2e specs
This commit is contained in:
@@ -39,7 +39,7 @@ function mockNodeList(commands?: string[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
callGateway.mockReset();
|
callGateway.mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("nodes camera_snap", () => {
|
describe("nodes camera_snap", () => {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ function createSandbox(overrides?: Partial<SandboxContext>): SandboxContext {
|
|||||||
|
|
||||||
describe("sandbox fs bridge shell compatibility", () => {
|
describe("sandbox fs bridge shell compatibility", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockedExecDockerRaw.mockReset();
|
mockedExecDockerRaw.mockClear();
|
||||||
mockedExecDockerRaw.mockImplementation(async (args) => {
|
mockedExecDockerRaw.mockImplementation(async (args) => {
|
||||||
const script = args[5] ?? "";
|
const script = args[5] ?? "";
|
||||||
if (script.includes('stat -c "%F|%s|%Y"')) {
|
if (script.includes('stat -c "%F|%s|%Y"')) {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ describe("sessions_spawn requesterOrigin threading", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const callGatewayMock = getCallGatewayMock();
|
const callGatewayMock = getCallGatewayMock();
|
||||||
resetSubagentRegistryForTests();
|
resetSubagentRegistryForTests();
|
||||||
callGatewayMock.mockReset();
|
callGatewayMock.mockClear();
|
||||||
setSessionsSpawnConfigOverride({
|
setSessionsSpawnConfigOverride({
|
||||||
session: {
|
session: {
|
||||||
mainKey: "main",
|
mainKey: "main",
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ describe("emitSubagentEndedHookOnce", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
lifecycleMocks.getGlobalHookRunner.mockReset();
|
lifecycleMocks.getGlobalHookRunner.mockClear();
|
||||||
lifecycleMocks.runSubagentEnded.mockClear();
|
lifecycleMocks.runSubagentEnded.mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ describe("announce loop guard (#18264)", () => {
|
|||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.useRealTimers();
|
vi.useRealTimers();
|
||||||
loadSubagentRegistryFromDisk.mockReset();
|
loadSubagentRegistryFromDisk.mockClear();
|
||||||
loadSubagentRegistryFromDisk.mockReturnValue(new Map());
|
loadSubagentRegistryFromDisk.mockReturnValue(new Map());
|
||||||
saveSubagentRegistryToDisk.mockClear();
|
saveSubagentRegistryToDisk.mockClear();
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { readLatestAssistantReply } from "./agent-step.js";
|
|||||||
|
|
||||||
describe("readLatestAssistantReply", () => {
|
describe("readLatestAssistantReply", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
callGatewayMock.mockReset();
|
callGatewayMock.mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns the most recent assistant message when compaction markers trail history", async () => {
|
it("returns the most recent assistant message when compaction markers trail history", async () => {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { createCronTool } from "./cron-tool.js";
|
|||||||
|
|
||||||
describe("cron tool flat-params", () => {
|
describe("cron tool flat-params", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
callGatewayToolMock.mockReset();
|
callGatewayToolMock.mockClear();
|
||||||
callGatewayToolMock.mockResolvedValue({ ok: true });
|
callGatewayToolMock.mockResolvedValue({ ok: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ function stubJsonFetchOk() {
|
|||||||
describe("fetchBrowserJson loopback auth", () => {
|
describe("fetchBrowserJson loopback auth", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.restoreAllMocks();
|
vi.restoreAllMocks();
|
||||||
mocks.loadConfig.mockReset();
|
mocks.loadConfig.mockClear();
|
||||||
mocks.loadConfig.mockReturnValue({
|
mocks.loadConfig.mockReturnValue({
|
||||||
gateway: {
|
gateway: {
|
||||||
auth: {
|
auth: {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ describe("nodes run: approval transport timeout (#12098)", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
callGatewaySpy.mockReset();
|
callGatewaySpy.mockClear();
|
||||||
callGatewaySpy.mockResolvedValue({ decision: "allow-once" });
|
callGatewaySpy.mockResolvedValue({ decision: "allow-once" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const { clearInternalHooks, createInternalHookEvent, registerInternalHook, trigg
|
|||||||
|
|
||||||
describe("boot-md startup hook integration", () => {
|
describe("boot-md startup hook integration", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
runBootOnce.mockReset();
|
runBootOnce.mockClear();
|
||||||
clearInternalHooks();
|
clearInternalHooks();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ describe("startGmailWatcherWithLogs", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
startGmailWatcherMock.mockReset();
|
startGmailWatcherMock.mockClear();
|
||||||
log.info.mockClear();
|
log.info.mockClear();
|
||||||
log.warn.mockClear();
|
log.warn.mockClear();
|
||||||
log.error.mockClear();
|
log.error.mockClear();
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ describe("applyMediaUnderstanding", () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockedResolveApiKey.mockClear();
|
mockedResolveApiKey.mockClear();
|
||||||
mockedFetchRemoteMedia.mockReset();
|
mockedFetchRemoteMedia.mockClear();
|
||||||
mockedFetchRemoteMedia.mockResolvedValue({
|
mockedFetchRemoteMedia.mockResolvedValue({
|
||||||
buffer: Buffer.from([0, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),
|
buffer: Buffer.from([0, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),
|
||||||
contentType: "audio/ogg",
|
contentType: "audio/ogg",
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ describe("memory search async sync", () => {
|
|||||||
}) as OpenClawConfig;
|
}) as OpenClawConfig;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
embedBatch.mockReset();
|
embedBatch.mockClear();
|
||||||
embedBatch.mockImplementation(async (input: string[]) => input.map(() => [0.2, 0.2, 0.2]));
|
embedBatch.mockImplementation(async (input: string[]) => input.map(() => [0.2, 0.2, 0.2]));
|
||||||
workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-mem-async-"));
|
workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-mem-async-"));
|
||||||
indexPath = path.join(workspaceDir, "index.sqlite");
|
indexPath = path.join(workspaceDir, "index.sqlite");
|
||||||
|
|||||||
Reference in New Issue
Block a user