test(core): use lightweight clears in runtime and telegram setup

This commit is contained in:
Peter Steinberger
2026-02-22 08:09:14 +00:00
parent 2557945a8d
commit e893157600
5 changed files with 11 additions and 8 deletions

View File

@@ -36,8 +36,8 @@ const { withTempHome } = createTempHomeHarness({ prefix: "openclaw-rawbody-" });
describe("RawBody directive parsing", () => {
beforeEach(() => {
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
agentMocks.runEmbeddedPiAgent.mockReset();
agentMocks.loadModelCatalog.mockReset();
agentMocks.runEmbeddedPiAgent.mockClear();
agentMocks.loadModelCatalog.mockClear();
agentMocks.loadModelCatalog.mockResolvedValue([
{ id: "claude-opus-4-5", name: "Opus 4.5", provider: "anthropic" },
]);

View File

@@ -10,7 +10,7 @@ import { createPluginRuntime } from "./index.js";
describe("plugin runtime command execution", () => {
beforeEach(() => {
runCommandWithTimeoutMock.mockReset();
runCommandWithTimeoutMock.mockClear();
});
it("exposes runtime.system.runCommandWithTimeout by default", async () => {

View File

@@ -326,9 +326,12 @@ describe("telegram stickers", () => {
const STICKER_TEST_TIMEOUT_MS = process.platform === "win32" ? 30_000 : 20_000;
beforeEach(() => {
cacheStickerSpy.mockReset();
getCachedStickerSpy.mockReset();
describeStickerImageSpy.mockReset();
cacheStickerSpy.mockClear();
getCachedStickerSpy.mockClear();
describeStickerImageSpy.mockClear();
// Re-seed defaults so per-test overrides do not leak when using mockClear.
getCachedStickerSpy.mockReturnValue(undefined);
describeStickerImageSpy.mockReturnValue(undefined);
});
it(

View File

@@ -121,7 +121,7 @@ describe("resolveTelegramAutoSelectFamilyDecision", () => {
});
it("memoizes WSL2 detection across repeated defaults", () => {
vi.mocked(isWSL2Sync).mockReset();
vi.mocked(isWSL2Sync).mockClear();
vi.mocked(isWSL2Sync).mockReturnValue(false);
resolveTelegramAutoSelectFamilyDecision({ env: {}, nodeMajor: 22 });
resolveTelegramAutoSelectFamilyDecision({ env: {}, nodeMajor: 22 });

View File

@@ -19,7 +19,7 @@ import { selectStyled } from "./prompt-select-styled.js";
describe("selectStyled", () => {
beforeEach(() => {
selectMock.mockReset();
selectMock.mockClear();
stylePromptMessageMock.mockClear();
stylePromptHintMock.mockClear();
});