@@ -11,6 +11,7 @@ import {
1111 getHeaderContext ,
1212 getMetaContent ,
1313} from '../../src/browser/browsertracing' ;
14+ import { DEFAULT_METRICS_INSTR_OPTIONS , MetricsInstrumentation } from '../../src/browser/metrics' ;
1415import { defaultRequestInstrumentationOptions } from '../../src/browser/request' ;
1516import { instrumentRoutingWithDefaults } from '../../src/browser/router' ;
1617import * as hubExtensions from '../../src/hubextensions' ;
@@ -32,6 +33,8 @@ jest.mock('@sentry/utils', () => {
3233 } ;
3334} ) ;
3435
36+ jest . mock ( '../../src/browser/metrics' ) ;
37+
3538const { logger } = jest . requireActual ( '@sentry/utils' ) ;
3639const warnSpy = jest . spyOn ( logger , 'warn' ) ;
3740
@@ -493,4 +496,31 @@ describe('BrowserTracing', () => {
493496 ) ;
494497 } ) ;
495498 } ) ;
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+ } ) ;
496526} ) ;
0 commit comments