test(core): reduce mock reset overhead across unit and e2e specs

This commit is contained in:
Peter Steinberger
2026-02-22 08:22:52 +00:00
parent d06ad6bc55
commit 8a0a28763e
13 changed files with 13 additions and 13 deletions

View File

@@ -39,7 +39,7 @@ function mockNodeList(commands?: string[]) {
}
beforeEach(() => {
callGateway.mockReset();
callGateway.mockClear();
});
describe("nodes camera_snap", () => {

View File

@@ -26,7 +26,7 @@ function createSandbox(overrides?: Partial<SandboxContext>): SandboxContext {
describe("sandbox fs bridge shell compatibility", () => {
beforeEach(() => {
mockedExecDockerRaw.mockReset();
mockedExecDockerRaw.mockClear();
mockedExecDockerRaw.mockImplementation(async (args) => {
const script = args[5] ?? "";
if (script.includes('stat -c "%F|%s|%Y"')) {

View File

@@ -32,7 +32,7 @@ describe("sessions_spawn requesterOrigin threading", () => {
beforeEach(() => {
const callGatewayMock = getCallGatewayMock();
resetSubagentRegistryForTests();
callGatewayMock.mockReset();
callGatewayMock.mockClear();
setSessionsSpawnConfigOverride({
session: {
mainKey: "main",

View File

@@ -42,7 +42,7 @@ describe("emitSubagentEndedHookOnce", () => {
};
beforeEach(() => {
lifecycleMocks.getGlobalHookRunner.mockReset();
lifecycleMocks.getGlobalHookRunner.mockClear();
lifecycleMocks.runSubagentEnded.mockClear();
});

View File

@@ -70,7 +70,7 @@ describe("announce loop guard (#18264)", () => {
afterEach(() => {
vi.useRealTimers();
loadSubagentRegistryFromDisk.mockReset();
loadSubagentRegistryFromDisk.mockClear();
loadSubagentRegistryFromDisk.mockReturnValue(new Map());
saveSubagentRegistryToDisk.mockClear();
vi.clearAllMocks();

View File

@@ -9,7 +9,7 @@ import { readLatestAssistantReply } from "./agent-step.js";
describe("readLatestAssistantReply", () => {
beforeEach(() => {
callGatewayMock.mockReset();
callGatewayMock.mockClear();
});
it("returns the most recent assistant message when compaction markers trail history", async () => {

View File

@@ -12,7 +12,7 @@ import { createCronTool } from "./cron-tool.js";
describe("cron tool flat-params", () => {
beforeEach(() => {
callGatewayToolMock.mockReset();
callGatewayToolMock.mockClear();
callGatewayToolMock.mockResolvedValue({ ok: true });
});

View File

@@ -46,7 +46,7 @@ function stubJsonFetchOk() {
describe("fetchBrowserJson loopback auth", () => {
beforeEach(() => {
vi.restoreAllMocks();
mocks.loadConfig.mockReset();
mocks.loadConfig.mockClear();
mocks.loadConfig.mockReturnValue({
gateway: {
auth: {

View File

@@ -40,7 +40,7 @@ describe("nodes run: approval transport timeout (#12098)", () => {
});
beforeEach(() => {
callGatewaySpy.mockReset();
callGatewaySpy.mockClear();
callGatewaySpy.mockResolvedValue({ decision: "allow-once" });
});

View File

@@ -19,7 +19,7 @@ const { clearInternalHooks, createInternalHookEvent, registerInternalHook, trigg
describe("boot-md startup hook integration", () => {
beforeEach(() => {
runBootOnce.mockReset();
runBootOnce.mockClear();
clearInternalHooks();
});

View File

@@ -18,7 +18,7 @@ describe("startGmailWatcherWithLogs", () => {
};
beforeEach(() => {
startGmailWatcherMock.mockReset();
startGmailWatcherMock.mockClear();
log.info.mockClear();
log.warn.mockClear();
log.error.mockClear();

View File

@@ -141,7 +141,7 @@ describe("applyMediaUnderstanding", () => {
beforeEach(() => {
mockedResolveApiKey.mockClear();
mockedFetchRemoteMedia.mockReset();
mockedFetchRemoteMedia.mockClear();
mockedFetchRemoteMedia.mockResolvedValue({
buffer: Buffer.from([0, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),
contentType: "audio/ogg",

View File

@@ -42,7 +42,7 @@ describe("memory search async sync", () => {
}) as OpenClawConfig;
beforeEach(async () => {
embedBatch.mockReset();
embedBatch.mockClear();
embedBatch.mockImplementation(async (input: string[]) => input.map(() => [0.2, 0.2, 0.2]));
workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-mem-async-"));
indexPath = path.join(workspaceDir, "index.sqlite");