@@ -11,6 +11,7 @@ import {
11
11
getHeaderContext ,
12
12
getMetaContent ,
13
13
} from '../../src/browser/browsertracing' ;
14
+ import { DEFAULT_METRICS_INSTR_OPTIONS , MetricsInstrumentation } from '../../src/browser/metrics' ;
14
15
import { defaultRequestInstrumentationOptions } from '../../src/browser/request' ;
15
16
import { instrumentRoutingWithDefaults } from '../../src/browser/router' ;
16
17
import * as hubExtensions from '../../src/hubextensions' ;
@@ -32,6 +33,8 @@ jest.mock('@sentry/utils', () => {
32
33
} ;
33
34
} ) ;
34
35
36
+ jest . mock ( '../../src/browser/metrics' ) ;
37
+
35
38
const { logger } = jest . requireActual ( '@sentry/utils' ) ;
36
39
const warnSpy = jest . spyOn ( logger , 'warn' ) ;
37
40
@@ -493,4 +496,31 @@ describe('BrowserTracing', () => {
493
496
) ;
494
497
} ) ;
495
498
} ) ;
499
+
500
+ describe ( 'metrics' , ( ) => {
501
+ beforeEach ( ( ) => {
502
+ // @ts -ignore mock clear
503
+ MetricsInstrumentation . mockClear ( ) ;
504
+ } ) ;
505
+
506
+ it ( 'creates metrics instrumentation' , ( ) => {
507
+ createBrowserTracing ( true , { } ) ;
508
+
509
+ expect ( MetricsInstrumentation ) . toHaveBeenCalledTimes ( 1 ) ;
510
+ expect ( MetricsInstrumentation ) . toHaveBeenLastCalledWith ( DEFAULT_METRICS_INSTR_OPTIONS ) ;
511
+ } ) ;
512
+
513
+ it ( 'creates metrics instrumentation with custom options' , ( ) => {
514
+ createBrowserTracing ( true , {
515
+ _metricOptions : {
516
+ _reportAllChanges : true ,
517
+ } ,
518
+ } ) ;
519
+
520
+ expect ( MetricsInstrumentation ) . toHaveBeenCalledTimes ( 1 ) ;
521
+ expect ( MetricsInstrumentation ) . toHaveBeenLastCalledWith ( {
522
+ _reportAllChanges : true ,
523
+ } ) ;
524
+ } ) ;
525
+ } ) ;
496
526
} ) ;
0 commit comments