@@ -67,60 +67,58 @@ describe('Sentry client SDK', () => {
6767 expect ( browserTracing ) . toBeDefined ( ) ;
6868 } ) ;
6969
70- it ( 'merges the BrowserTracing integration with the user-provided one' , ( ) => { } ) ;
71- } ) ;
70+ it . each ( [
71+ [ 'enableTracing' , { enableTracing : false } ] ,
72+ [ 'no tracing option set' , { } ] ,
73+ ] ) ( "doesn't add the BrowserTracing integration if tracing is disabled via %s" , ( _ , tracingOptions ) => {
74+ init ( {
75+ dsn :
'https://[email protected] /1337' , 76+ ...tracingOptions ,
77+ } ) ;
78+
79+ const integrationsToInit = svelteInit . mock . calls [ 0 ] [ 0 ] . integrations ;
80+ const browserTracing = ( getCurrentHub ( ) . getClient ( ) as BrowserClient ) ?. getIntegrationById ( 'BrowserTracing' ) ;
7281
73- it . each ( [
74- [ 'enableTracing' , { enableTracing : false } ] ,
75- [ 'no tracing option set' , { } ] ,
76- ] ) ( "doesn't add the BrowserTracing integration if tracing is disabled via %s" , ( _ , tracingOptions ) => {
77- init ( {
78- dsn :
'https://[email protected] /1337' , 79- ...tracingOptions ,
82+ expect ( integrationsToInit ) . not . toContainEqual ( expect . objectContaining ( { name : 'BrowserTracing' } ) ) ;
83+ expect ( browserTracing ) . toBeUndefined ( ) ;
8084 } ) ;
8185
82- const integrationsToInit = svelteInit . mock . calls [ 0 ] [ 0 ] . integrations ;
83- const browserTracing = ( getCurrentHub ( ) . getClient ( ) as BrowserClient ) ?. getIntegrationById ( 'BrowserTracing' ) ;
86+ it ( "doesn't add the BrowserTracing integration if `__SENTRY_TRACING__` is set to false" , ( ) => {
87+ // This is the closest we can get to unit-testing the `__SENTRY_TRACING__` tree-shaking guard
88+ // IRL, the code to add the integration would most likely be removed by the bundler.
8489
85- expect ( integrationsToInit ) . not . toContainEqual ( expect . objectContaining ( { name : 'BrowserTracing' } ) ) ;
86- expect ( browserTracing ) . toBeUndefined ( ) ;
87- } ) ;
90+ globalThis . __SENTRY_TRACING__ = false ;
8891
89- it ( "doesn't add the BrowserTracing integration if `__SENTRY_TRACING__` is set to false" , ( ) => {
90- // This is the closest we can get to unit-testing the `__SENTRY_TRACING__` tree-shaking guard
91- // IRL, the code to add the integration would most likely be removed by the bundler.
92+ init ( {
93+ dsn :
'https://[email protected] /1337' , 94+ enableTracing : true ,
95+ } ) ;
9296
93- globalThis . __SENTRY_TRACING__ = false ;
97+ const integrationsToInit = svelteInit . mock . calls [ 0 ] [ 0 ] . integrations ;
98+ const browserTracing = ( getCurrentHub ( ) . getClient ( ) as BrowserClient ) ?. getIntegrationById ( 'BrowserTracing' ) ;
9499
95- init ( {
96- dsn :
'https://[email protected] /1337' , 97- enableTracing : true ,
98- } ) ;
100+ expect ( integrationsToInit ) . not . toContainEqual ( expect . objectContaining ( { name : 'BrowserTracing' } ) ) ;
101+ expect ( browserTracing ) . toBeUndefined ( ) ;
99102
100- const integrationsToInit = svelteInit . mock . calls [ 0 ] [ 0 ] . integrations ;
101- const browserTracing = ( getCurrentHub ( ) . getClient ( ) as BrowserClient ) ?. getIntegrationById ( 'BrowserTracing' ) ;
103+ delete globalThis . __SENTRY_TRACING__ ;
104+ } ) ;
102105
103- expect ( integrationsToInit ) . not . toContainEqual ( expect . objectContaining ( { name : 'BrowserTracing' } ) ) ;
104- expect ( browserTracing ) . toBeUndefined ( ) ;
106+ // TODO: this test is only meaningful once we have a routing instrumentation which we always want to add
107+ // to a user-provided BrowserTracing integration (see NextJS SDK)
108+ it . skip ( 'Merges the user-provided BrowserTracing integration with the automatically added one' , ( ) => {
109+ init ( {
110+ dsn :
'https://[email protected] /1337' , 111+ integrations : [ new BrowserTracing ( { tracePropagationTargets : [ 'myDomain.com' ] } ) ] ,
112+ enableTracing : true ,
113+ } ) ;
105114
106- delete globalThis . __SENTRY_TRACING__ ;
107- } ) ;
115+ const integrationsToInit = svelteInit . mock . calls [ 0 ] [ 0 ] . integrations ;
116+ const browserTracing = ( getCurrentHub ( ) . getClient ( ) as BrowserClient ) ?. getIntegrationById ( 'BrowserTracing' ) ;
108117
109- // TODO: this test is only meaningful once we have a routing instrumentation which we always want to add
110- // to a user-provided BrowserTracing integration (see NextJS SDK)
111- it . skip ( 'Merges the user-provided BrowserTracing integration with the automatically added one' , ( ) => {
112- init ( {
113- dsn :
'https://[email protected] /1337' , 114- integrations : [ new BrowserTracing ( { tracePropagationTargets : [ 'myDomain.com' ] } ) ] ,
115- enableTracing : true ,
118+ expect ( integrationsToInit ) . toContainEqual ( expect . objectContaining ( { name : 'BrowserTracing' } ) ) ;
119+ expect ( browserTracing ) . toBeDefined ( ) ;
120+ expect ( ( browserTracing as BrowserTracing ) . options . tracePropagationTargets ) . toEqual ( [ 'myDomain.com' ] ) ;
116121 } ) ;
117-
118- const integrationsToInit = svelteInit . mock . calls [ 0 ] [ 0 ] . integrations ;
119- const browserTracing = ( getCurrentHub ( ) . getClient ( ) as BrowserClient ) ?. getIntegrationById ( 'BrowserTracing' ) ;
120-
121- expect ( integrationsToInit ) . toContainEqual ( expect . objectContaining ( { name : 'BrowserTracing' } ) ) ;
122- expect ( browserTracing ) . toBeDefined ( ) ;
123- expect ( ( browserTracing as BrowserTracing ) . options . tracePropagationTargets ) . toEqual ( [ 'myDomain.com' ] ) ;
124122 } ) ;
125123 } ) ;
126124} ) ;
0 commit comments