Skip to content

Commit c8cdea6

Browse files
committed
test(dashboard-agent): restore AWS/provider env vars after model-provider tests
afterEach deleted these unconditionally, which could clobber CI-provided AWS config for later test files. Snapshot in beforeEach and restore the exact prior value (or delete if previously unset).
1 parent efd963a commit c8cdea6

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

internal-packages/dashboard-agent/src/model-provider.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { afterEach, describe, expect, it } from "vitest";
1+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
22
import { PROMPT_CACHE_CONTROL } from "./prompt-prefix";
33
import {
44
BEDROCK_MODEL_IDS,
@@ -25,10 +25,20 @@ const AWS_ENV_VARS = [
2525
"AWS_DEFAULT_REGION",
2626
] as const;
2727

28-
afterEach(() => {
28+
let priorEnv: Record<string, string | undefined>;
29+
30+
beforeEach(() => {
31+
priorEnv = Object.fromEntries(AWS_ENV_VARS.map((key) => [key, process.env[key]]));
2932
for (const key of AWS_ENV_VARS) delete process.env[key];
3033
});
3134

35+
afterEach(() => {
36+
for (const key of AWS_ENV_VARS) {
37+
if (priorEnv[key] === undefined) delete process.env[key];
38+
else process.env[key] = priorEnv[key];
39+
}
40+
});
41+
3242
describe("resolveDashboardAgentModel", () => {
3343
it("resolves a canonical prompt string against Anthropic by default", () => {
3444
expect(resolveDashboardAgentModel("anthropic:claude-sonnet-4-6").modelId).toBe(

0 commit comments

Comments
 (0)