test: speed up cli and model command suites

This commit is contained in:
Peter Steinberger
2026-03-24 17:13:59 +00:00
parent 4518f6e820
commit 6e20c26397
5 changed files with 24 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
const callGateway = vi.fn();
@@ -18,9 +18,12 @@ vi.mock("../utils/message-channel.js", () => ({
let resolveCommandSecretRefsViaGateway: typeof import("./command-secret-gateway.js").resolveCommandSecretRefsViaGateway;
beforeEach(async () => {
beforeAll(async () => {
vi.resetModules();
({ resolveCommandSecretRefsViaGateway } = await import("./command-secret-gateway.js"));
});
beforeEach(() => {
callGateway.mockReset();
});

View File

@@ -1,5 +1,5 @@
import { Command } from "commander";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
const listChannelPairingRequests = vi.fn();
const approveChannelPairingCode = vi.fn();
@@ -47,9 +47,12 @@ vi.mock("../config/config.js", () => ({
describe("pairing cli", () => {
let registerPairingCli: typeof import("./pairing-cli.js").registerPairingCli;
beforeEach(async () => {
beforeAll(async () => {
vi.resetModules();
({ registerPairingCli } = await import("./pairing-cli.js"));
});
beforeEach(() => {
listChannelPairingRequests.mockClear();
listChannelPairingRequests.mockResolvedValue([]);
approveChannelPairingCode.mockClear();