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