diff --git a/test/safe-teardown.test.js b/test/safe-teardown.test.js index 9b21f10..cb07d2e 100644 --- a/test/safe-teardown.test.js +++ b/test/safe-teardown.test.js @@ -1,10 +1,19 @@ import assert from "node:assert/strict" import { Buffer } from "node:buffer" import http from "node:http" -import test from "node:test" +import test, { beforeEach } from "node:test" import { createProxyFetchHandler, sweepStaleProxySessions } from "../index.js" +// Keep the suite hermetic: OPENCODE_LLM_PROXY_* variables from the developer's +// shell or CI (e.g. a token, host or port) must not change outcomes. Tests that +// need a specific value set it inside the test body, after this hook has run. +beforeEach(() => { + for (const name of Object.keys(process.env)) { + if (name.startsWith("OPENCODE_LLM_PROXY_")) delete process.env[name] + } +}) + const TOKENS = { input: 2, output: 1, reasoning: 0, cache: { read: 0, write: 0 } } function createMockClient({ promptMode = "hang", streamEvents = null } = {}) {