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(() => {
|
||||
callGateway.mockReset();
|
||||
callGateway.mockClear();
|
||||
});
|
||||
|
||||
describe("nodes camera_snap", () => {
|
||||
|
||||
@@ -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"')) {
|
||||
|
||||
@@ -32,7 +32,7 @@ describe("sessions_spawn requesterOrigin threading", () => {
|
||||
beforeEach(() => {
|
||||
const callGatewayMock = getCallGatewayMock();
|
||||
resetSubagentRegistryForTests();
|
||||
callGatewayMock.mockReset();
|
||||
callGatewayMock.mockClear();
|
||||
setSessionsSpawnConfigOverride({
|
||||
session: {
|
||||
mainKey: "main",
|
||||
|
||||
@@ -42,7 +42,7 @@ describe("emitSubagentEndedHookOnce", () => {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
lifecycleMocks.getGlobalHookRunner.mockReset();
|
||||
lifecycleMocks.getGlobalHookRunner.mockClear();
|
||||
lifecycleMocks.runSubagentEnded.mockClear();
|
||||
});
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ describe("announce loop guard (#18264)", () => {
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
loadSubagentRegistryFromDisk.mockReset();
|
||||
loadSubagentRegistryFromDisk.mockClear();
|
||||
loadSubagentRegistryFromDisk.mockReturnValue(new Map());
|
||||
saveSubagentRegistryToDisk.mockClear();
|
||||
vi.clearAllMocks();
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -12,7 +12,7 @@ import { createCronTool } from "./cron-tool.js";
|
||||
|
||||
describe("cron tool flat-params", () => {
|
||||
beforeEach(() => {
|
||||
callGatewayToolMock.mockReset();
|
||||
callGatewayToolMock.mockClear();
|
||||
callGatewayToolMock.mockResolvedValue({ ok: true });
|
||||
});
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ function stubJsonFetchOk() {
|
||||
describe("fetchBrowserJson loopback auth", () => {
|
||||
beforeEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
mocks.loadConfig.mockReset();
|
||||
mocks.loadConfig.mockClear();
|
||||
mocks.loadConfig.mockReturnValue({
|
||||
gateway: {
|
||||
auth: {
|
||||
|
||||
@@ -40,7 +40,7 @@ describe("nodes run: approval transport timeout (#12098)", () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
callGatewaySpy.mockReset();
|
||||
callGatewaySpy.mockClear();
|
||||
callGatewaySpy.mockResolvedValue({ decision: "allow-once" });
|
||||
});
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ const { clearInternalHooks, createInternalHookEvent, registerInternalHook, trigg
|
||||
|
||||
describe("boot-md startup hook integration", () => {
|
||||
beforeEach(() => {
|
||||
runBootOnce.mockReset();
|
||||
runBootOnce.mockClear();
|
||||
clearInternalHooks();
|
||||
});
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ describe("startGmailWatcherWithLogs", () => {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
startGmailWatcherMock.mockReset();
|
||||
startGmailWatcherMock.mockClear();
|
||||
log.info.mockClear();
|
||||
log.warn.mockClear();
|
||||
log.error.mockClear();
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user