perf(test): reduce vitest logging overhead and media fixture cost

This commit is contained in:
Peter Steinberger
2026-02-14 00:59:53 +00:00
parent 31d8546afd
commit e8377799bb
4 changed files with 11 additions and 6 deletions

View File

@@ -67,7 +67,7 @@ describe("logger helpers", () => {
it("uses daily rolling default log file and prunes old ones", () => { it("uses daily rolling default log file and prunes old ones", () => {
resetLogger(); resetLogger();
setLoggerOverride({}); // force defaults regardless of user config setLoggerOverride({ level: "info" }); // force default file path with enabled file logging
const today = localDateString(new Date()); const today = localDateString(new Date());
const todayPath = path.join(DEFAULT_LOG_DIR, `openclaw-${today}.log`); const todayPath = path.join(DEFAULT_LOG_DIR, `openclaw-${today}.log`);

View File

@@ -37,6 +37,9 @@ function normalizeConsoleLevel(level?: string): LogLevel {
if (isVerbose()) { if (isVerbose()) {
return "debug"; return "debug";
} }
if (!level && process.env.VITEST === "true" && process.env.OPENCLAW_TEST_CONSOLE !== "1") {
return "silent";
}
return normalizeLogLevel(level, "info"); return normalizeLogLevel(level, "info");
} }

View File

@@ -63,7 +63,9 @@ function resolveSettings(): ResolvedSettings {
cfg = undefined; cfg = undefined;
} }
} }
const level = normalizeLogLevel(cfg?.level, "info"); const defaultLevel =
process.env.VITEST === "true" && process.env.OPENCLAW_TEST_FILE_LOG !== "1" ? "silent" : "info";
const level = normalizeLogLevel(cfg?.level, defaultLevel);
const file = cfg?.file ?? defaultRollingPathForToday(); const file = cfg?.file ?? defaultRollingPathForToday();
return { level, file }; return { level, file };
} }

View File

@@ -146,8 +146,8 @@ describe("web auto-reply", () => {
const smallPng = await sharp({ const smallPng = await sharp({
create: { create: {
width: 200, width: 64,
height: 200, height: 64,
channels: 3, channels: 3,
background: { r: 0, g: 255, b: 0 }, background: { r: 0, g: 255, b: 0 },
}, },
@@ -251,8 +251,8 @@ describe("web auto-reply", () => {
const bigPng = await sharp({ const bigPng = await sharp({
create: { create: {
width: 3200, width: 2000,
height: 3200, height: 2000,
channels: 3, channels: 3,
background: { r: 255, g: 0, b: 0 }, background: { r: 255, g: 0, b: 0 },
}, },