refactor(test): snapshot tailscale test env per case

This commit is contained in:
Peter Steinberger
2026-02-21 18:36:09 +00:00
parent 2a0ea7cb97
commit 1b585b2959

View File

@@ -1,4 +1,5 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { captureEnv } from "../test-utils/env.js";
import * as tailscale from "./tailscale.js";
const {
@@ -12,18 +13,15 @@ const {
const tailscaleBin = expect.stringMatching(/tailscale$/i);
describe("tailscale helpers", () => {
const originalForcedBinary = process.env.OPENCLAW_TEST_TAILSCALE_BINARY;
let envSnapshot: ReturnType<typeof captureEnv>;
beforeEach(() => {
envSnapshot = captureEnv(["OPENCLAW_TEST_TAILSCALE_BINARY"]);
process.env.OPENCLAW_TEST_TAILSCALE_BINARY = "tailscale";
});
afterEach(() => {
if (originalForcedBinary === undefined) {
delete process.env.OPENCLAW_TEST_TAILSCALE_BINARY;
} else {
process.env.OPENCLAW_TEST_TAILSCALE_BINARY = originalForcedBinary;
}
envSnapshot.restore();
vi.restoreAllMocks();
});