1
1
import * as SentryBrowser from '@sentry/browser' ;
2
- import { SDK_VERSION } from '@sentry/vue' ;
2
+ import { type BrowserClient , SDK_VERSION , getClient } from '@sentry/vue' ;
3
3
import { beforeEach , describe , expect , it , vi } from 'vitest' ;
4
4
import { init } from '../../src/client' ;
5
5
6
- const vueInit = vi . spyOn ( SentryBrowser , 'init' ) ;
6
+ const browserInit = vi . spyOn ( SentryBrowser , 'init' ) ;
7
7
8
8
describe ( 'Nuxt Client SDK' , ( ) => {
9
9
describe ( 'init' , ( ) => {
@@ -12,7 +12,7 @@ describe('Nuxt Client SDK', () => {
12
12
} ) ;
13
13
14
14
it ( 'Adds Nuxt metadata to the SDK options' , ( ) => {
15
- expect ( vueInit ) . not . toHaveBeenCalled ( ) ;
15
+ expect ( browserInit ) . not . toHaveBeenCalled ( ) ;
16
16
17
17
init ( {
18
18
dsn :
'https://[email protected] /1337' ,
@@ -31,8 +31,25 @@ describe('Nuxt Client SDK', () => {
31
31
} ,
32
32
} ;
33
33
34
- expect ( vueInit ) . toHaveBeenCalledTimes ( 1 ) ;
35
- expect ( vueInit ) . toHaveBeenLastCalledWith ( expect . objectContaining ( expectedMetadata ) ) ;
34
+ expect ( browserInit ) . toHaveBeenCalledTimes ( 1 ) ;
35
+ expect ( browserInit ) . toHaveBeenLastCalledWith ( expect . objectContaining ( expectedMetadata ) ) ;
36
+ } ) ;
37
+
38
+ describe ( 'Automatically adds BrowserTracing integration' , ( ) => {
39
+ it . each ( [
40
+ [ 'tracesSampleRate' , { tracesSampleRate : 0 } ] ,
41
+ [ 'tracesSampler' , { tracesSampler : ( ) => 1.0 } ] ,
42
+ [ 'enableTracing' , { enableTracing : true } ] ,
43
+ [ 'no tracing option set' , { } ] /* enable "tracing without performance" by default */ ,
44
+ ] ) ( 'adds a browserTracingIntegration if tracing is enabled via %s' , ( _ , tracingOptions ) => {
45
+ init ( {
46
+ dsn :
'https://[email protected] /1337' ,
47
+ ...tracingOptions ,
48
+ } ) ;
49
+
50
+ const browserTracing = getClient < BrowserClient > ( ) ?. getIntegrationByName ( 'BrowserTracing' ) ;
51
+ expect ( browserTracing ) . toBeDefined ( ) ;
52
+ } ) ;
36
53
} ) ;
37
54
38
55
it ( 'returns client from init' , ( ) => {
0 commit comments