diff --git a/src/logging/log-tail-redaction.test.ts b/src/logging/log-tail-redaction.test.ts index 257f7906e670..3cda6f9db3d7 100644 --- a/src/logging/log-tail-redaction.test.ts +++ b/src/logging/log-tail-redaction.test.ts @@ -4,9 +4,10 @@ import os from "node:os"; import path from "node:path"; import { afterEach, describe, expect, it } from "vitest"; import { resetLogger, setLoggerOverride } from "../logging.js"; +import { captureEnv } from "../test-utils/env.js"; import { readConfiguredLogTail } from "./log-tail.js"; -const originalConfigPath = process.env.OPENCLAW_CONFIG_PATH; +const originalEnv = captureEnv(["OPENCLAW_CONFIG_PATH"]); let tempDirs: string[] = []; async function makeTempDir(): Promise { @@ -16,11 +17,7 @@ async function makeTempDir(): Promise { } afterEach(async () => { - if (originalConfigPath === undefined) { - delete process.env.OPENCLAW_CONFIG_PATH; - } else { - process.env.OPENCLAW_CONFIG_PATH = originalConfigPath; - } + originalEnv.restore(); setLoggerOverride(null); resetLogger(); await Promise.all(tempDirs.map((dir) => fs.rm(dir, { force: true, recursive: true })));