@@ -3,6 +3,7 @@ import * as SentrySolid from '@sentry/solid';
33
44import { vi } from 'vitest' ;
55import { init as solidStartInit } from '../../src/client' ;
6+ import { solidRouterBrowserTracingIntegration } from '../../src/client/solidrouter' ;
67
78const browserInit = vi . spyOn ( SentrySolid , 'init' ) ;
89
@@ -34,3 +35,43 @@ describe('Initialize Solid Start SDK', () => {
3435 expect ( browserInit ) . toHaveBeenLastCalledWith ( expect . objectContaining ( expectedMetadata ) ) ;
3536 } ) ;
3637} ) ;
38+
39+ describe ( 'browserTracingIntegration' , ( ) => {
40+ it ( 'adds the `browserTracingIntegration` when `__SENTRY_TRACING__` is not set' , ( ) => {
41+ const client = solidStartInit ( {
42+ dsn : 'https://public@dsn.ingest.sentry.io/1337' ,
43+ } ) ;
44+
45+ const browserTracingIntegration = client ?. getOptions ( ) . integrations . find ( integration => integration . name === 'BrowserTracing' ) ;
46+ expect ( browserTracingIntegration ) . toBeDefined ( ) ;
47+ expect ( browserTracingIntegration ! . isDefaultInstance ) . toEqual ( true ) ;
48+ } ) ;
49+
50+ it ( "doesn't add the `browserTracingIntegration` if `__SENTRY_TRACING__` is false" , ( ) => {
51+ // @ts -expect-error Test setup for build-time flag
52+ globalThis . __SENTRY_TRACING__ = false ;
53+
54+ const client = solidStartInit ( {
55+ dsn : 'https://public@dsn.ingest.sentry.io/1337' ,
56+ } ) ;
57+
58+ const browserTracingIntegration = client ?. getOptions ( ) . integrations . find ( integration => integration . name === 'BrowserTracing' ) ;
59+ expect ( browserTracingIntegration ) . toBeUndefined ( ) ;
60+
61+ // @ts -expect-error Test setup for build-time flag
62+ delete globalThis . __SENTRY_TRACING__ ;
63+ } ) ;
64+
65+ it ( "doesn't add the default `browserTracingIntegration` if `solidBrowserTracingIntegration` was already passed in" , ( ) => {
66+ const client = solidStartInit ( {
67+ integrations : [
68+ solidRouterBrowserTracingIntegration ( ) ,
69+ ] ,
70+ dsn : 'https://public@dsn.ingest.sentry.io/1337' ,
71+ } ) ;
72+
73+ const browserTracingIntegration = client ?. getOptions ( ) . integrations . find ( integration => integration . name === 'BrowserTracing' ) ;
74+ expect ( browserTracingIntegration ) . toBeDefined ( ) ;
75+ expect ( browserTracingIntegration ! . isDefaultInstance ) . toBeUndefined ( ) ;
76+ } )
77+ } ) ;
0 commit comments