@@ -26,6 +26,9 @@ addDOMPropertiesToGlobal(['XMLHttpRequest', 'Event', 'location', 'document']);
2626describe ( 'Hub' , ( ) => {
2727 afterEach ( ( ) => {
2828 jest . clearAllMocks ( ) ;
29+ // Reset global carrier to the initial state
30+ const hub = new Hub ( ) ;
31+ makeMain ( hub ) ;
2932 } ) ;
3033
3134 describe ( 'getTransaction()' , ( ) => {
@@ -125,6 +128,13 @@ describe('Hub', () => {
125128 expect ( transaction . sampled ) . toBe ( true ) ;
126129 } ) ;
127130
131+ it ( 'should set sampled = true if tracesSampleRate is 1 (without global hub)' , ( ) => {
132+ const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 1 } ) ) ;
133+ const transaction = hub . startTransaction ( { name : 'dogpark' } ) ;
134+
135+ expect ( transaction . sampled ) . toBe ( true ) ;
136+ } ) ;
137+
128138 it ( "should call tracesSampler if it's defined" , ( ) => {
129139 const tracesSampler = jest . fn ( ) ;
130140 const hub = new Hub ( new BrowserClient ( { tracesSampler } ) ) ;
@@ -154,6 +164,15 @@ describe('Hub', () => {
154164 expect ( transaction . sampled ) . toBe ( true ) ;
155165 } ) ;
156166
167+ it ( 'should set sampled = true if tracesSampler returns 1 (without global hub)' , ( ) => {
168+ const tracesSampler = jest . fn ( ) . mockReturnValue ( 1 ) ;
169+ const hub = new Hub ( new BrowserClient ( { tracesSampler } ) ) ;
170+ const transaction = hub . startTransaction ( { name : 'dogpark' } ) ;
171+
172+ expect ( tracesSampler ) . toHaveBeenCalled ( ) ;
173+ expect ( transaction . sampled ) . toBe ( true ) ;
174+ } ) ;
175+
157176 it ( 'should not try to override explicitly set positive sampling decision' , ( ) => {
158177 // so that the decision otherwise would be false
159178 const tracesSampler = jest . fn ( ) . mockReturnValue ( 0 ) ;
0 commit comments