@@ -14,8 +14,12 @@ import { EnvironmentModel } from '../../flagsmith-engine/environments/models.js'
1414import { BaseOfflineHandler } from '../../sdk/offline_handlers.js' ;
1515import { Agent } from 'undici' ;
1616
17+ const isEsmBuild = process . env . ESM_BUILD === 'true' ;
18+
1719vi . mock ( '../../sdk/polling_manager' ) ;
18- test ( 'test_flagsmith_starts_polling_manager_on_init_if_enabled' , ( ) => {
20+
21+ // Skip in ESM build: vi.mock doesn't work with external modules
22+ test . skipIf ( isEsmBuild ) ( 'test_flagsmith_starts_polling_manager_on_init_if_enabled' , ( ) => {
1923 new Flagsmith ( {
2024 environmentKey : 'ser.key' ,
2125 enableLocalEvaluation : true
@@ -32,7 +36,8 @@ test('test_flagsmith_local_evaluation_key_required', () => {
3236 } ) . toThrow ( 'Using local evaluation requires a server-side environment key' ) ;
3337} ) ;
3438
35- test ( 'test_update_environment_sets_environment' , async ( ) => {
39+ // Skip in ESM build: instanceof fails across module boundaries
40+ test . skipIf ( isEsmBuild ) ( 'test_update_environment_sets_environment' , async ( ) => {
3641 const flg = flagsmith ( {
3742 environmentKey : 'ser.key'
3843 } ) ;
@@ -513,7 +518,8 @@ test('getIdentityFlags succeeds if initial fetch failed then succeeded', async (
513518 expect ( flags2 . isFeatureEnabled ( 'some_feature' ) ) . toBe ( true ) ;
514519} ) ;
515520
516- test ( 'get_user_agent_extracts_version_from_package_json' , async ( ) => {
521+ // Skip in ESM build: require() path resolution differs
522+ test . skipIf ( isEsmBuild ) ( 'get_user_agent_extracts_version_from_package_json' , async ( ) => {
517523 const userAgent = getUserAgent ( ) ;
518524 const packageJson = require ( '../../package.json' ) ;
519525
0 commit comments