@@ -13,7 +13,13 @@ import type { Integration } from '@sentry/types';
1313import  {  logger  }  from  '@sentry/utils' ; 
1414import  {  JSDOM  }  from  'jsdom' ; 
1515
16- import  {  BrowserTracing ,  breadcrumbsIntegration ,  init ,  nextRouterInstrumentation  }  from  '../src/client' ; 
16+ import  { 
17+   BrowserTracing , 
18+   breadcrumbsIntegration , 
19+   browserTracingIntegration  as  nextjsBrowserTracingIntegration , 
20+   init , 
21+   nextRouterInstrumentation , 
22+ }  from  '../src/client' ; 
1723
1824const  reactInit  =  jest . spyOn ( SentryReact ,  'init' ) ; 
1925const  captureEvent  =  jest . spyOn ( BaseClient . prototype ,  'captureEvent' ) ; 
@@ -174,11 +180,7 @@ describe('Client init()', () => {
174180      // It is a "new" browser tracing integration 
175181      expect ( typeof  integration ?. afterAllSetup ) . toBe ( 'function' ) ; 
176182
177-       // This shows that the user-configured options are still here 
178-       expect ( integration ?. options ?. finalTimeout ) . toEqual ( 10 ) ; 
179-       expect ( integration ?. options . instrumentNavigation ) . toBe ( false ) ; 
180-       expect ( integration ?. options . instrumentPageLoad ) . toBe ( true ) ; 
181- 
183+       // the hooks is correctly invoked 
182184      expect ( beforeStartSpan ) . toHaveBeenCalledTimes ( 1 ) ; 
183185      expect ( beforeStartSpan ) . toHaveBeenCalledWith ( 
184186        expect . objectContaining ( { 
@@ -187,11 +189,49 @@ describe('Client init()', () => {
187189        } ) , 
188190      ) ; 
189191
190-       // it is the svelte kit variety 
192+       // it correctly starts the page load span 
193+       expect ( getActiveSpan ( ) ) . toBeDefined ( ) ; 
194+       expect ( spanToJSON ( getActiveSpan ( ) ! ) . data ?. [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] ) . toEqual ( 
195+         'auto.pageload.nextjs.app_router_instrumentation' , 
196+       ) ; 
197+ 
198+       // This shows that the user-configured options are still here 
199+       expect ( integration ?. options . finalTimeout ) . toEqual ( 10 ) ; 
200+       expect ( integration ?. options . instrumentNavigation ) . toBe ( false ) ; 
201+       expect ( integration ?. options . instrumentPageLoad ) . toBe ( true ) ; 
202+     } ) ; 
203+ 
204+     it ( 'forces correct router instrumentation if user provides Next.js `browserTracingIntegration` ' ,  ( )  =>  { 
205+       init ( { 
206+         dsn : TEST_DSN , 
207+         integrations : [ 
208+           nextjsBrowserTracingIntegration ( { 
209+             finalTimeout : 10 , 
210+             instrumentNavigation : false , 
211+           } ) , 
212+         ] , 
213+         enableTracing : true , 
214+       } ) ; 
215+ 
216+       const  client  =  getClient < BrowserClient > ( ) ! ; 
217+       // eslint-disable-next-line deprecation/deprecation 
218+       const  integration  =  client . getIntegrationByName < ReturnType < typeof  browserTracingIntegration > > ( 'BrowserTracing' ) ; 
219+ 
220+       expect ( integration ) . toBeDefined ( ) ; 
221+ 
222+       // It is a "new" browser tracing integration 
223+       expect ( typeof  integration ?. afterAllSetup ) . toBe ( 'function' ) ; 
224+ 
225+       // it correctly starts the pageload span 
191226      expect ( getActiveSpan ( ) ) . toBeDefined ( ) ; 
192227      expect ( spanToJSON ( getActiveSpan ( ) ! ) . data ?. [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] ) . toEqual ( 
193228        'auto.pageload.nextjs.app_router_instrumentation' , 
194229      ) ; 
230+ 
231+       // This shows that the user-configured options are still here 
232+       expect ( integration ?. options . finalTimeout ) . toEqual ( 10 ) ; 
233+       expect ( integration ?. options . instrumentNavigation ) . toBe ( false ) ; 
234+       expect ( integration ?. options . instrumentPageLoad ) . toBe ( true ) ; 
195235    } ) ; 
196236
197237    it ( 'forces correct router instrumentation if user provides `BrowserTracing` in a function' ,  ( )  =>  { 
0 commit comments