From ad227c5b46d3d563f56e6833655a173dbfb9ac29 Mon Sep 17 00:00:00 2001 From: Mikey Date: Wed, 2 Sep 2026 09:52:12 -0700 Subject: [PATCH] Fix CLI test runner preload and test-utils fallback for public mirror --- cli/bunfig.toml | 1 - cli/src/__tests__/test-utils.ts | 37 ++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/cli/bunfig.toml b/cli/bunfig.toml index 828dbd0b2c..20e59ae30e 100644 --- a/cli/bunfig.toml +++ b/cli/bunfig.toml @@ -13,6 +13,5 @@ # which is why CI filters those with `find ... ! -name` instead. preload = [ "../sdk/test/setup-env.ts", - "../test/setup-scm-loader.ts", "./test/setup-agents-artifact.ts", ] diff --git a/cli/src/__tests__/test-utils.ts b/cli/src/__tests__/test-utils.ts index 5280c5ec84..1fe7f598cf 100644 --- a/cli/src/__tests__/test-utils.ts +++ b/cli/src/__tests__/test-utils.ts @@ -121,23 +121,30 @@ function loadCliEnv(): Record { try { ensureCliEnvDefaults() - // NOTE: Inline require() is used for lazy loading - the env module depends on - // Infisical secrets which may not be available at module load time in test environments - const { env } = require('../../../packages/internal/src/env') as { - env: Record - } + try { + const { env } = require('../../../packages/internal/src/env') as { + env: Record + } - cachedEnv = Object.entries(env).reduce>( - (acc, [key, value]) => { - if (value !== undefined && value !== null) { - acc[key] = String(value) - } - return acc - }, - {}, - ) + cachedEnv = Object.entries(env).reduce>( + (acc, [key, value]) => { + if (value !== undefined && value !== null) { + acc[key] = String(value) + } + return acc + }, + {}, + ) - return cachedEnv + return cachedEnv + } catch { + // Fallback for public mirror where packages/internal is not present + cachedEnv = { + ...TEST_CLIENT_ENV_DEFAULTS, + ...TEST_SERVER_ENV_DEFAULTS, + } + return cachedEnv + } } catch (error) { const message = error instanceof Error