11import * as SentryBrowser from '@sentry/browser' ;
2- import { SDK_VERSION } from '@sentry/vue' ;
2+ import { type BrowserClient , SDK_VERSION , getClient } from '@sentry/vue' ;
33import { beforeEach , describe , expect , it , vi } from 'vitest' ;
44import { init } from '../../src/client' ;
55
6- const vueInit = vi . spyOn ( SentryBrowser , 'init' ) ;
6+ const browserInit = vi . spyOn ( SentryBrowser , 'init' ) ;
77
88describe ( 'Nuxt Client SDK' , ( ) => {
99 describe ( 'init' , ( ) => {
@@ -12,7 +12,7 @@ describe('Nuxt Client SDK', () => {
1212 } ) ;
1313
1414 it ( 'Adds Nuxt metadata to the SDK options' , ( ) => {
15- expect ( vueInit ) . not . toHaveBeenCalled ( ) ;
15+ expect ( browserInit ) . not . toHaveBeenCalled ( ) ;
1616
1717 init ( {
1818 dsn : 'https://public@dsn.ingest.sentry.io/1337' ,
@@ -31,8 +31,25 @@ describe('Nuxt Client SDK', () => {
3131 } ,
3232 } ;
3333
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://public@dsn.ingest.sentry.io/1337' ,
47+ ...tracingOptions ,
48+ } ) ;
49+
50+ const browserTracing = getClient < BrowserClient > ( ) ?. getIntegrationByName ( 'BrowserTracing' ) ;
51+ expect ( browserTracing ) . toBeDefined ( ) ;
52+ } ) ;
3653 } ) ;
3754
3855 it ( 'returns client from init' , ( ) => {
0 commit comments