perf(test): trim module resets in config suites

This commit is contained in:
Peter Steinberger
2026-02-13 15:04:43 +00:00
parent a5faea614b
commit 79f4c4c584
10 changed files with 23 additions and 154 deletions

View File

@@ -2,12 +2,11 @@ import fs from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";
import { describe, expect, it, vi } from "vitest";
import { loadConfig, validateConfigObject } from "./config.js";
import { withTempHome } from "./test-helpers.js";
describe("multi-agent agentDir validation", () => {
it("rejects shared agents.list agentDir", async () => {
vi.resetModules();
const { validateConfigObject } = await import("./config.js");
const shared = path.join(tmpdir(), "openclaw-shared-agentdir");
const res = validateConfigObject({
agents: {
@@ -46,9 +45,7 @@ describe("multi-agent agentDir validation", () => {
"utf-8",
);
vi.resetModules();
const spy = vi.spyOn(console, "error").mockImplementation(() => {});
const { loadConfig } = await import("./config.js");
expect(() => loadConfig()).toThrow(/duplicate agentDir/i);
expect(spy.mock.calls.flat().join(" ")).toMatch(/Duplicate agentDir/i);
spy.mockRestore();