From d2afc5cd934724b5cdca8334e5d04bf1ffca4519 Mon Sep 17 00:00:00 2001 From: "continue[bot]" Date: Wed, 10 Dec 2025 19:04:31 +0000 Subject: [PATCH] fix(openai-adapters): Fix Vercel SDK test API initialization timing The beforeAll() approach created the API instance at the wrong time, before the feature flag check was evaluated. Moving to describe-time env var setting with inline API factory call ensures the API is created after the flag is set. This matches the pattern used successfully in the comparison tests within the same file. Co-authored-by: nate Generated with [Continue](https://continue.dev) Co-Authored-By: Continue --- .../openai-adapters/src/test/vercel-sdk.test.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/openai-adapters/src/test/vercel-sdk.test.ts b/packages/openai-adapters/src/test/vercel-sdk.test.ts index 051750990..17d594051 100644 --- a/packages/openai-adapters/src/test/vercel-sdk.test.ts +++ b/packages/openai-adapters/src/test/vercel-sdk.test.ts @@ -29,24 +29,25 @@ function testVercelProvider(config: VercelTestConfig, featureFlag: string) { describe(`${config.provider}/${config.model} (Vercel SDK)`, () => { vi.setConfig({ testTimeout: 30000 }); - let api: any; + // Set feature flag at describe-time (before test collection) + process.env[featureFlag] = "true"; - // Set feature flag and create API instance AFTER flag is set - beforeAll(() => { - process.env[featureFlag] = "true"; - api = getLlmApi({ + // Create a factory that makes fresh API instances for each test + // This ensures the API is created AFTER the feature flag is set + const apiFactory = () => { + return getLlmApi({ provider: config.provider as any, apiKey: config.apiKey, apiBase: config.apiBase, env: config.env, }); - }); + }; afterAll(() => { delete process.env[featureFlag]; }); - testChat(api, model, { + testChat(apiFactory(), model, { skipTools: skipTools ?? false, expectUsage: expectUsage ?? true, skipSystemMessage: skipSystemMessage ?? false,