11import  {  debug  }  from  '@sentry/core' ; 
2- import  {  afterEach ,  describe ,  expect ,  it ,  vi  }  from  'vitest' ; 
2+ import  {  afterEach ,  beforeEach ,  describe ,  expect ,  it ,  vi  }  from  'vitest' ; 
3+ import  {  resetGlobals  }  from  '../helpers/mockSdkInit' ; 
34
45describe ( 'preload' ,  ( )  =>  { 
6+   beforeEach ( ( )  =>  { 
7+     // Mock this to prevent conflicts with other tests 
8+     vi . mock ( '../../src/integrations/tracing' ,  async  ( importOriginal : ( )  =>  Promise < Record < string ,  unknown > > )  =>  { 
9+       const  actual  =  await  importOriginal ( ) ; 
10+       return  { 
11+         ...actual , 
12+         getOpenTelemetryInstrumentationToPreload : ( )  =>  [ 
13+           Object . assign ( vi . fn ( ) ,  {  id : 'Http.sentry'  } ) , 
14+           Object . assign ( vi . fn ( ) ,  {  id : 'Http'  } ) , 
15+           Object . assign ( vi . fn ( ) ,  {  id : 'Express'  } ) , 
16+           Object . assign ( vi . fn ( ) ,  {  id : 'Graphql'  } ) , 
17+         ] , 
18+       } ; 
19+     } ) ; 
20+   } ) ; 
21+ 
522  afterEach ( ( )  =>  { 
6-     vi . resetAllMocks ( ) ; 
723    debug . disable ( ) ; 
24+     resetGlobals ( ) ; 
825
926    delete  process . env . SENTRY_DEBUG ; 
1027    delete  process . env . SENTRY_PRELOAD_INTEGRATIONS ; 
@@ -29,6 +46,7 @@ describe('preload', () => {
2946
3047    await  import ( '../../src/preload' ) ; 
3148
49+     expect ( logSpy ) . toHaveBeenCalledWith ( 'Sentry Logger [log]:' ,  '[Sentry] Preloaded Http.sentry instrumentation' ) ; 
3250    expect ( logSpy ) . toHaveBeenCalledWith ( 'Sentry Logger [log]:' ,  '[Sentry] Preloaded Http instrumentation' ) ; 
3351    expect ( logSpy ) . toHaveBeenCalledWith ( 'Sentry Logger [log]:' ,  '[Sentry] Preloaded Express instrumentation' ) ; 
3452    expect ( logSpy ) . toHaveBeenCalledWith ( 'Sentry Logger [log]:' ,  '[Sentry] Preloaded Graphql instrumentation' ) ; 
@@ -44,6 +62,7 @@ describe('preload', () => {
4462
4563    await  import ( '../../src/preload' ) ; 
4664
65+     expect ( logSpy ) . toHaveBeenCalledWith ( 'Sentry Logger [log]:' ,  '[Sentry] Preloaded Http.sentry instrumentation' ) ; 
4766    expect ( logSpy ) . toHaveBeenCalledWith ( 'Sentry Logger [log]:' ,  '[Sentry] Preloaded Http instrumentation' ) ; 
4867    expect ( logSpy ) . toHaveBeenCalledWith ( 'Sentry Logger [log]:' ,  '[Sentry] Preloaded Express instrumentation' ) ; 
4968    expect ( logSpy ) . not . toHaveBeenCalledWith ( 'Sentry Logger [log]:' ,  '[Sentry] Preloaded Graphql instrumentation' ) ; 
0 commit comments