1- import type { BrowserClient } from '@sentry/browser' ;
21import {
32 browserTracingIntegration ,
43 getActiveSpan ,
5- getClient ,
64 getCurrentScope ,
75 getGlobalScope ,
86 getIsolationScope ,
@@ -12,7 +10,7 @@ import * as SentryBrowser from '@sentry/browser';
1210import { afterEach , describe , expect , it , vi } from 'vitest' ;
1311import { init } from '../../src/client/sdk' ;
1412
15- const browserInit = vi . spyOn ( SentryBrowser , 'init ' ) ;
13+ const browserInit = vi . spyOn ( SentryBrowser , 'initWithDefaultIntegrations ' ) ;
1614
1715describe ( 'Sentry client SDK' , ( ) => {
1816 describe ( 'init' , ( ) => {
@@ -44,6 +42,7 @@ describe('Sentry client SDK', () => {
4442 } ,
4543 } ,
4644 } ) ,
45+ expect . any ( Function ) ,
4746 ) ;
4847 } ) ;
4948
@@ -53,45 +52,39 @@ describe('Sentry client SDK', () => {
5352 [ 'tracesSampler' , { tracesSampler : ( ) => 1.0 } ] ,
5453 [ 'no tracing option set' , { } ] ,
5554 ] ) ( 'adds browserTracingIntegration if tracing is enabled via %s' , ( _ , tracingOptions ) => {
56- init ( {
55+ const client = init ( {
5756 dsn :
'https://[email protected] /1337' , 5857 ...tracingOptions ,
5958 } ) ;
6059
61- const integrationsToInit = browserInit . mock . calls [ 0 ] ! [ 0 ] ?. defaultIntegrations ;
62- const browserTracing = getClient < BrowserClient > ( ) ?. getIntegrationByName ( 'BrowserTracing' ) ;
63-
64- expect ( integrationsToInit ) . toContainEqual ( expect . objectContaining ( { name : 'BrowserTracing' } ) ) ;
60+ const browserTracing = client ?. getIntegrationByName ( 'BrowserTracing' ) ;
6561 expect ( browserTracing ) . toBeDefined ( ) ;
6662 } ) ;
6763
6864 it ( "doesn't add browserTracingIntegration if `__SENTRY_TRACING__` is set to false" , ( ) => {
6965 ( globalThis as any ) . __SENTRY_TRACING__ = false ;
7066
71- init ( {
67+ const client = init ( {
7268 dsn :
'https://[email protected] /1337' , 7369 tracesSampleRate : 1 ,
7470 } ) ;
7571
76- const integrationsToInit = browserInit . mock . calls [ 0 ] ! [ 0 ] ?. defaultIntegrations || [ ] ;
77- const browserTracing = getClient < BrowserClient > ( ) ?. getIntegrationByName ( 'BrowserTracing' ) ;
78-
79- expect ( integrationsToInit ) . not . toContainEqual ( expect . objectContaining ( { name : 'BrowserTracing' } ) ) ;
72+ const browserTracing = client ?. getIntegrationByName ( 'BrowserTracing' ) ;
8073 expect ( browserTracing ) . toBeUndefined ( ) ;
8174
8275 delete ( globalThis as any ) . __SENTRY_TRACING__ ;
8376 } ) ;
8477
8578 it ( 'Overrides the automatically default browserTracingIntegration instance with a a user-provided browserTracingIntegration instance' , ( ) => {
86- init ( {
79+ const client = init ( {
8780 dsn :
'https://[email protected] /1337' , 8881 integrations : [
8982 browserTracingIntegration ( { finalTimeout : 10 , instrumentNavigation : false , instrumentPageLoad : false } ) ,
9083 ] ,
9184 tracesSampleRate : 1 ,
9285 } ) ;
9386
94- const browserTracing = getClient < BrowserClient > ( ) ?. getIntegrationByName ( 'BrowserTracing' ) ;
87+ const browserTracing = client ?. getIntegrationByName ( 'BrowserTracing' ) ;
9588 expect ( browserTracing ) . toBeDefined ( ) ;
9689
9790 // no active span means the settings were respected
0 commit comments