@@ -192,6 +192,13 @@ describe('Hub', () => {
192
192
expect ( logger . warn ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Sample rate must be a boolean or a number' ) ) ;
193
193
} ) ;
194
194
195
+ it ( 'should reject tracesSampleRates which are NaN' , ( ) => {
196
+ const hub = new Hub ( new BrowserClient ( { tracesSampleRate : 'dogs!' as any } ) ) ;
197
+ hub . startTransaction ( { name : 'dogpark' } ) ;
198
+
199
+ expect ( logger . warn ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Sample rate must be a boolean or a number' ) ) ;
200
+ } ) ;
201
+
195
202
// the rate might be a boolean, but for our purposes, false is equivalent to 0 and true is equivalent to 1
196
203
it ( 'should reject tracesSampleRates less than 0' , ( ) => {
197
204
const hub = new Hub ( new BrowserClient ( { tracesSampleRate : - 26 } ) ) ;
@@ -216,6 +223,14 @@ describe('Hub', () => {
216
223
expect ( logger . warn ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Sample rate must be a boolean or a number' ) ) ;
217
224
} ) ;
218
225
226
+ it ( 'should reject tracesSampler return values which are NaN' , ( ) => {
227
+ const tracesSampler = jest . fn ( ) . mockReturnValue ( NaN ) ;
228
+ const hub = new Hub ( new BrowserClient ( { tracesSampler } ) ) ;
229
+ hub . startTransaction ( { name : 'dogpark' } ) ;
230
+
231
+ expect ( logger . warn ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Sample rate must be a boolean or a number' ) ) ;
232
+ } ) ;
233
+
219
234
// the rate might be a boolean, but for our purposes, false is equivalent to 0 and true is equivalent to 1
220
235
it ( 'should reject tracesSampler return values less than 0' , ( ) => {
221
236
const tracesSampler = jest . fn ( ) . mockReturnValue ( - 12 ) ;
@@ -260,11 +275,11 @@ describe('Hub', () => {
260
275
} ) ;
261
276
262
277
it ( 'should propagate sampling decision to child transactions in XHR header' , ( ) => {
263
- // TODO this doesn't currently happen, but it should
278
+ // TODO fix this and write the test
264
279
} ) ;
265
280
266
281
it ( 'should propagate sampling decision to child transactions in fetch header' , ( ) => {
267
- // TODO this doesn't currently happen, but it should
282
+ // TODO fix this and write the test
268
283
} ) ;
269
284
270
285
it ( "should inherit parent's sampling decision when creating a new transaction if tracesSampler is undefined" , ( ) => {
0 commit comments