@@ -11,6 +11,7 @@ import {
11
11
} from '../../src/browser/browsertracing' ;
12
12
import { defaultRequestInstrumentionOptions } from '../../src/browser/request' ;
13
13
import { defaultRoutingInstrumentation } from '../../src/browser/router' ;
14
+ import * as hubExtensions from '../../src/hubextensions' ;
14
15
import { DEFAULT_IDLE_TIMEOUT , IdleTransaction } from '../../src/idletransaction' ;
15
16
import { getActiveTransaction , secToMs } from '../../src/utils' ;
16
17
@@ -209,12 +210,26 @@ describe('BrowserTracing', () => {
209
210
const name = 'sentry-trace' ;
210
211
const content = '126de09502ae4e0fb26c6967190756a4-b6e54397b12a2a0f-1' ;
211
212
document . head . innerHTML = `<meta name="${ name } " content="${ content } ">` ;
213
+ const startIdleTransaction = jest . spyOn ( hubExtensions , 'startIdleTransaction' ) ;
214
+
212
215
createBrowserTracing ( true , { routingInstrumentation : customRoutingInstrumentation } ) ;
213
- const transaction = getActiveTransaction ( hub ) as IdleTransaction ;
214
216
215
- expect ( transaction . traceId ) . toBe ( '126de09502ae4e0fb26c6967190756a4' ) ;
216
- expect ( transaction . parentSpanId ) . toBe ( 'b6e54397b12a2a0f' ) ;
217
- expect ( transaction . sampled ) . toBe ( true ) ;
217
+ // we match on the calls themselves (rather than calling .toHaveBeenCalledWith()) because that method requires all
218
+ // of the arguments be supplied, when we really only care about the transaction context which gets passed
219
+ expect ( startIdleTransaction . mock . calls ) . toEqual (
220
+ // all calls
221
+ expect . arrayContaining ( [
222
+ // all arguments
223
+ expect . arrayContaining ( [
224
+ // one of the arguments
225
+ expect . objectContaining ( {
226
+ traceId : '126de09502ae4e0fb26c6967190756a4' ,
227
+ parentSpanId : 'b6e54397b12a2a0f' ,
228
+ parentSampled : true ,
229
+ } ) ,
230
+ ] ) ,
231
+ ] ) ,
232
+ ) ;
218
233
} ) ;
219
234
220
235
describe ( 'idleTimeout' , ( ) => {
@@ -342,20 +357,24 @@ describe('BrowserTracing', () => {
342
357
} ) ;
343
358
} ) ;
344
359
345
- describe ( 'getMeta' , ( ) => {
346
- it ( 'returns a found meta tag contents' , ( ) => {
347
- const name = 'sentry-trace' ;
348
- const content = '126de09502ae4e0fb26c6967190756a4-b6e54397b12a2a0f-1' ;
349
- document . head . innerHTML = `<meta name="${ name } " content="${ content } ">` ;
360
+ describe ( 'sentry-trace <meta> element' , ( ) => {
361
+ describe ( 'getMetaContent' , ( ) => {
362
+ it ( 'finds the specified tag and extracts the value' , ( ) => {
363
+ const name = 'sentry-trace' ;
364
+ const content = '126de09502ae4e0fb26c6967190756a4-b6e54397b12a2a0f-1' ;
365
+ document . head . innerHTML = `<meta name="${ name } " content="${ content } ">` ;
350
366
351
- const meta = getMetaContent ( name ) ;
352
- expect ( meta ) . toBe ( content ) ;
353
- } ) ;
367
+ const metaTagValue = getMetaContent ( name ) ;
368
+ expect ( metaTagValue ) . toBe ( content ) ;
369
+ } ) ;
354
370
355
- it ( 'only returns meta tags queried for' , ( ) => {
356
- document . head . innerHTML = `<meta name="not-test ">` ;
371
+ it ( "doesn't return meta tags other than the one specified" , ( ) => {
372
+ document . head . innerHTML = `<meta name="cat-cafe ">` ;
357
373
358
- const meta = getMetaContent ( 'test' ) ;
359
- expect ( meta ) . toBe ( null ) ;
374
+ const metaTagValue = getMetaContent ( 'dogpark' ) ;
375
+ expect ( metaTagValue ) . toBe ( null ) ;
376
+ } ) ;
377
+
378
+ } ) ;
360
379
} ) ;
361
380
} ) ;
0 commit comments