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 <nate@continue.dev> Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <noreply@continue.dev>
This commit is contained in:
parent
be61972bbd
commit
d2afc5cd93
1 changed files with 8 additions and 7 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue