test: speed up core runtime suites

This commit is contained in:
Peter Steinberger
2026-03-31 02:12:14 +01:00
parent f7285e0a9e
commit 6b6ddcd2a6
93 changed files with 874 additions and 980 deletions

View File

@@ -1,4 +1,17 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
const mocks = vi.hoisted(() => ({
sendExecApprovalFollowup: vi.fn(),
logWarn: vi.fn(),
}));
vi.mock("./bash-tools.exec-approval-followup.js", () => ({
sendExecApprovalFollowup: mocks.sendExecApprovalFollowup,
}));
vi.mock("../logger.js", () => ({
logWarn: mocks.logWarn,
}));
let sendExecApprovalFollowupResult: typeof import("./bash-tools.exec-host-shared.js").sendExecApprovalFollowupResult;
let maxExecApprovalFollowupFailureLogKeys: typeof import("./bash-tools.exec-host-shared.js").MAX_EXEC_APPROVAL_FOLLOWUP_FAILURE_LOG_KEYS;
@@ -6,20 +19,16 @@ let sendExecApprovalFollowup: typeof import("./bash-tools.exec-approval-followup
let logWarn: typeof import("../logger.js").logWarn;
describe("sendExecApprovalFollowupResult", () => {
beforeEach(async () => {
vi.resetModules();
vi.doMock("./bash-tools.exec-approval-followup.js", () => ({
sendExecApprovalFollowup: vi.fn(),
}));
vi.doMock("../logger.js", () => ({
logWarn: vi.fn(),
}));
beforeAll(async () => {
({
sendExecApprovalFollowupResult,
MAX_EXEC_APPROVAL_FOLLOWUP_FAILURE_LOG_KEYS: maxExecApprovalFollowupFailureLogKeys,
} = await import("./bash-tools.exec-host-shared.js"));
({ sendExecApprovalFollowup } = await import("./bash-tools.exec-approval-followup.js"));
({ logWarn } = await import("../logger.js"));
});
beforeEach(() => {
vi.mocked(sendExecApprovalFollowup).mockReset();
vi.mocked(logWarn).mockReset();
});