test: isolate browser navigation tests from host proxy env

This commit is contained in:
Shakker 2026-03-30 17:43:43 +01:00 committed by Shakker
parent 8746e2e216
commit e8b0d57eb6
1 changed files with 16 additions and 1 deletions

View File

@ -1,4 +1,4 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { SsrFBlockedError, type LookupFn } from "../infra/net/ssrf.js";
import {
assertBrowserNavigationAllowed,
@ -13,7 +13,22 @@ function createLookupFn(address: string): LookupFn {
return vi.fn(async () => [{ address, family }]) as unknown as LookupFn;
}
const PROXY_ENV_KEYS = [
"HTTP_PROXY",
"HTTPS_PROXY",
"ALL_PROXY",
"http_proxy",
"https_proxy",
"all_proxy",
] as const;
describe("browser navigation guard", () => {
beforeEach(() => {
for (const key of PROXY_ENV_KEYS) {
vi.stubEnv(key, "");
}
});
afterEach(() => {
vi.unstubAllEnvs();
});