@@ -110,13 +110,19 @@ describe('GCPFunction', () => {
110
110
} ;
111
111
const wrappedHandler = wrapHttpFunction ( handler ) ;
112
112
await handleHttp ( wrappedHandler ) ;
113
- expect ( Sentry . startTransaction ) . toBeCalledWith ( {
113
+
114
+ const fakeTransactionContext = {
114
115
name : 'POST /path' ,
115
116
op : 'gcp.function.http' ,
116
117
metadata : { baggage : [ { } , '' , true ] , source : 'route' } ,
117
- } ) ;
118
+ } ;
118
119
// @ts -ignore see "Why @ts-ignore" note
119
- expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( Sentry . fakeTransaction ) ;
120
+ const fakeTransaction = { ...Sentry . fakeTransaction , ...fakeTransactionContext } ;
121
+
122
+ // @ts -ignore see "Why @ts-ignore" note
123
+ expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
124
+ // @ts -ignore see "Why @ts-ignore" note
125
+ expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( fakeTransaction ) ;
120
126
// @ts -ignore see "Why @ts-ignore" note
121
127
expect ( Sentry . fakeTransaction . setHttpStatus ) . toBeCalledWith ( 200 ) ;
122
128
// @ts -ignore see "Why @ts-ignore" note
@@ -138,25 +144,29 @@ describe('GCPFunction', () => {
138
144
} ;
139
145
await handleHttp ( wrappedHandler , traceHeaders ) ;
140
146
141
- expect ( Sentry . startTransaction ) . toBeCalledWith (
142
- expect . objectContaining ( {
143
- name : 'POST /path' ,
144
- op : 'gcp.function.http' ,
145
- traceId : '12312012123120121231201212312012' ,
146
- parentSpanId : '1121201211212012' ,
147
- parentSampled : false ,
148
- metadata : {
149
- baggage : [
150
- {
151
- release : '2.12.1' ,
152
- } ,
153
- '' ,
154
- false ,
155
- ] ,
156
- source : 'route' ,
157
- } ,
158
- } ) ,
159
- ) ;
147
+ const fakeTransactionContext = {
148
+ name : 'POST /path' ,
149
+ op : 'gcp.function.http' ,
150
+ traceId : '12312012123120121231201212312012' ,
151
+ parentSpanId : '1121201211212012' ,
152
+ parentSampled : false ,
153
+ metadata : {
154
+ baggage : [
155
+ {
156
+ release : '2.12.1' ,
157
+ } ,
158
+ '' ,
159
+ false ,
160
+ ] ,
161
+ source : 'route' ,
162
+ } ,
163
+ } ;
164
+
165
+ // @ts -ignore see "Why @ts-ignore" note
166
+ expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
167
+
168
+ // @ts -ignore see "Why @ts-ignore" note
169
+ // expect(Sentry.fakeHub.startTransaction).toBeCalledWith(expect.objectContaining(fakeTransactionContext));
160
170
} ) ;
161
171
162
172
test ( 'capture error' , async ( ) => {
@@ -173,16 +183,22 @@ describe('GCPFunction', () => {
173
183
} ;
174
184
175
185
await handleHttp ( wrappedHandler , trace_headers ) ;
176
- expect ( Sentry . startTransaction ) . toBeCalledWith ( {
186
+
187
+ const fakeTransactionContext = {
177
188
name : 'POST /path' ,
178
189
op : 'gcp.function.http' ,
179
190
traceId : '12312012123120121231201212312012' ,
180
191
parentSpanId : '1121201211212012' ,
181
192
parentSampled : false ,
182
193
metadata : { baggage : [ { } , '' , false ] , source : 'route' } ,
183
- } ) ;
194
+ } ;
195
+ // @ts -ignore see "Why @ts-ignore" note
196
+ const fakeTransaction = { ...Sentry . fakeTransaction , ...fakeTransactionContext } ;
197
+
184
198
// @ts -ignore see "Why @ts-ignore" note
185
- expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( Sentry . fakeTransaction ) ;
199
+ expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
200
+ // @ts -ignore see "Why @ts-ignore" note
201
+ expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( fakeTransaction ) ;
186
202
expect ( Sentry . captureException ) . toBeCalledWith ( error ) ;
187
203
// @ts -ignore see "Why @ts-ignore" note
188
204
expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
@@ -246,13 +262,19 @@ describe('GCPFunction', () => {
246
262
} ;
247
263
const wrappedHandler = wrapEventFunction ( func ) ;
248
264
await expect ( handleEvent ( wrappedHandler ) ) . resolves . toBe ( 42 ) ;
249
- expect ( Sentry . startTransaction ) . toBeCalledWith ( {
265
+
266
+ const fakeTransactionContext = {
250
267
name : 'event.type' ,
251
268
op : 'gcp.function.event' ,
252
269
metadata : { source : 'component' } ,
253
- } ) ;
270
+ } ;
271
+ // @ts -ignore see "Why @ts-ignore" note
272
+ const fakeTransaction = { ...Sentry . fakeTransaction , ...fakeTransactionContext } ;
273
+
254
274
// @ts -ignore see "Why @ts-ignore" note
255
- expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( Sentry . fakeTransaction ) ;
275
+ expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
276
+ // @ts -ignore see "Why @ts-ignore" note
277
+ expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( fakeTransaction ) ;
256
278
// @ts -ignore see "Why @ts-ignore" note
257
279
expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
258
280
expect ( Sentry . flush ) . toBeCalledWith ( 2000 ) ;
@@ -267,13 +289,19 @@ describe('GCPFunction', () => {
267
289
} ;
268
290
const wrappedHandler = wrapEventFunction ( handler ) ;
269
291
await expect ( handleEvent ( wrappedHandler ) ) . rejects . toThrowError ( error ) ;
270
- expect ( Sentry . startTransaction ) . toBeCalledWith ( {
292
+
293
+ const fakeTransactionContext = {
271
294
name : 'event.type' ,
272
295
op : 'gcp.function.event' ,
273
296
metadata : { source : 'component' } ,
274
- } ) ;
297
+ } ;
298
+ // @ts -ignore see "Why @ts-ignore" note
299
+ const fakeTransaction = { ...Sentry . fakeTransaction , ...fakeTransactionContext } ;
300
+
301
+ // @ts -ignore see "Why @ts-ignore" note
302
+ expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
275
303
// @ts -ignore see "Why @ts-ignore" note
276
- expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( Sentry . fakeTransaction ) ;
304
+ expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( fakeTransaction ) ;
277
305
expect ( Sentry . captureException ) . toBeCalledWith ( error ) ;
278
306
// @ts -ignore see "Why @ts-ignore" note
279
307
expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
@@ -293,13 +321,19 @@ describe('GCPFunction', () => {
293
321
} ) ;
294
322
const wrappedHandler = wrapEventFunction ( func ) ;
295
323
await expect ( handleEvent ( wrappedHandler ) ) . resolves . toBe ( 42 ) ;
296
- expect ( Sentry . startTransaction ) . toBeCalledWith ( {
324
+
325
+ const fakeTransactionContext = {
297
326
name : 'event.type' ,
298
327
op : 'gcp.function.event' ,
299
328
metadata : { source : 'component' } ,
300
- } ) ;
329
+ } ;
301
330
// @ts -ignore see "Why @ts-ignore" note
302
- expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( Sentry . fakeTransaction ) ;
331
+ const fakeTransaction = { ...Sentry . fakeTransaction , ...fakeTransactionContext } ;
332
+
333
+ // @ts -ignore see "Why @ts-ignore" note
334
+ expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
335
+ // @ts -ignore see "Why @ts-ignore" note
336
+ expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( fakeTransaction ) ;
303
337
// @ts -ignore see "Why @ts-ignore" note
304
338
expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
305
339
expect ( Sentry . flush ) . toBeCalledWith ( 2000 ) ;
@@ -318,13 +352,19 @@ describe('GCPFunction', () => {
318
352
319
353
const wrappedHandler = wrapEventFunction ( handler ) ;
320
354
await expect ( handleEvent ( wrappedHandler ) ) . rejects . toThrowError ( error ) ;
321
- expect ( Sentry . startTransaction ) . toBeCalledWith ( {
355
+
356
+ const fakeTransactionContext = {
322
357
name : 'event.type' ,
323
358
op : 'gcp.function.event' ,
324
359
metadata : { source : 'component' } ,
325
- } ) ;
360
+ } ;
326
361
// @ts -ignore see "Why @ts-ignore" note
327
- expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( Sentry . fakeTransaction ) ;
362
+ const fakeTransaction = { ...Sentry . fakeTransaction , ...fakeTransactionContext } ;
363
+
364
+ // @ts -ignore see "Why @ts-ignore" note
365
+ expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
366
+ // @ts -ignore see "Why @ts-ignore" note
367
+ expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( fakeTransaction ) ;
328
368
expect ( Sentry . captureException ) . toBeCalledWith ( error ) ;
329
369
// @ts -ignore see "Why @ts-ignore" note
330
370
expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
@@ -341,13 +381,19 @@ describe('GCPFunction', () => {
341
381
} ;
342
382
const wrappedHandler = wrapEventFunction ( func ) ;
343
383
await expect ( handleEvent ( wrappedHandler ) ) . resolves . toBe ( 42 ) ;
344
- expect ( Sentry . startTransaction ) . toBeCalledWith ( {
384
+
385
+ const fakeTransactionContext = {
345
386
name : 'event.type' ,
346
387
op : 'gcp.function.event' ,
347
388
metadata : { source : 'component' } ,
348
- } ) ;
389
+ } ;
349
390
// @ts -ignore see "Why @ts-ignore" note
350
- expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( Sentry . fakeTransaction ) ;
391
+ const fakeTransaction = { ...Sentry . fakeTransaction , ...fakeTransactionContext } ;
392
+
393
+ // @ts -ignore see "Why @ts-ignore" note
394
+ expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
395
+ // @ts -ignore see "Why @ts-ignore" note
396
+ expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( fakeTransaction ) ;
351
397
// @ts -ignore see "Why @ts-ignore" note
352
398
expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
353
399
expect ( Sentry . flush ) . toBeCalledWith ( 2000 ) ;
@@ -362,13 +408,19 @@ describe('GCPFunction', () => {
362
408
} ;
363
409
const wrappedHandler = wrapEventFunction ( handler ) ;
364
410
await expect ( handleEvent ( wrappedHandler ) ) . rejects . toThrowError ( error ) ;
365
- expect ( Sentry . startTransaction ) . toBeCalledWith ( {
411
+
412
+ const fakeTransactionContext = {
366
413
name : 'event.type' ,
367
414
op : 'gcp.function.event' ,
368
415
metadata : { source : 'component' } ,
369
- } ) ;
416
+ } ;
417
+ // @ts -ignore see "Why @ts-ignore" note
418
+ const fakeTransaction = { ...Sentry . fakeTransaction , ...fakeTransactionContext } ;
419
+
420
+ // @ts -ignore see "Why @ts-ignore" note
421
+ expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
370
422
// @ts -ignore see "Why @ts-ignore" note
371
- expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( Sentry . fakeTransaction ) ;
423
+ expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( fakeTransaction ) ;
372
424
expect ( Sentry . captureException ) . toBeCalledWith ( error ) ;
373
425
// @ts -ignore see "Why @ts-ignore" note
374
426
expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
@@ -384,13 +436,19 @@ describe('GCPFunction', () => {
384
436
} ;
385
437
const wrappedHandler = wrapEventFunction ( handler ) ;
386
438
await expect ( handleEvent ( wrappedHandler ) ) . rejects . toThrowError ( error ) ;
387
- expect ( Sentry . startTransaction ) . toBeCalledWith ( {
439
+
440
+ const fakeTransactionContext = {
388
441
name : 'event.type' ,
389
442
op : 'gcp.function.event' ,
390
443
metadata : { source : 'component' } ,
391
- } ) ;
444
+ } ;
445
+ // @ts -ignore see "Why @ts-ignore" note
446
+ const fakeTransaction = { ...Sentry . fakeTransaction , ...fakeTransactionContext } ;
447
+
392
448
// @ts -ignore see "Why @ts-ignore" note
393
- expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( Sentry . fakeTransaction ) ;
449
+ expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
450
+ // @ts -ignore see "Why @ts-ignore" note
451
+ expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( fakeTransaction ) ;
394
452
expect ( Sentry . captureException ) . toBeCalledWith ( error ) ;
395
453
} ) ;
396
454
} ) ;
@@ -417,13 +475,19 @@ describe('GCPFunction', () => {
417
475
} ;
418
476
const wrappedHandler = wrapCloudEventFunction ( func ) ;
419
477
await expect ( handleCloudEvent ( wrappedHandler ) ) . resolves . toBe ( 42 ) ;
420
- expect ( Sentry . startTransaction ) . toBeCalledWith ( {
478
+
479
+ const fakeTransactionContext = {
421
480
name : 'event.type' ,
422
481
op : 'gcp.function.cloud_event' ,
423
482
metadata : { source : 'component' } ,
424
- } ) ;
483
+ } ;
484
+ // @ts -ignore see "Why @ts-ignore" note
485
+ const fakeTransaction = { ...Sentry . fakeTransaction , ...fakeTransactionContext } ;
486
+
425
487
// @ts -ignore see "Why @ts-ignore" note
426
- expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( Sentry . fakeTransaction ) ;
488
+ expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
489
+ // @ts -ignore see "Why @ts-ignore" note
490
+ expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( fakeTransaction ) ;
427
491
// @ts -ignore see "Why @ts-ignore" note
428
492
expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
429
493
expect ( Sentry . flush ) . toBeCalledWith ( 2000 ) ;
@@ -438,13 +502,19 @@ describe('GCPFunction', () => {
438
502
} ;
439
503
const wrappedHandler = wrapCloudEventFunction ( handler ) ;
440
504
await expect ( handleCloudEvent ( wrappedHandler ) ) . rejects . toThrowError ( error ) ;
441
- expect ( Sentry . startTransaction ) . toBeCalledWith ( {
505
+
506
+ const fakeTransactionContext = {
442
507
name : 'event.type' ,
443
508
op : 'gcp.function.cloud_event' ,
444
509
metadata : { source : 'component' } ,
445
- } ) ;
510
+ } ;
511
+ // @ts -ignore see "Why @ts-ignore" note
512
+ const fakeTransaction = { ...Sentry . fakeTransaction , ...fakeTransactionContext } ;
513
+
514
+ // @ts -ignore see "Why @ts-ignore" note
515
+ expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
446
516
// @ts -ignore see "Why @ts-ignore" note
447
- expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( Sentry . fakeTransaction ) ;
517
+ expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( fakeTransaction ) ;
448
518
expect ( Sentry . captureException ) . toBeCalledWith ( error ) ;
449
519
// @ts -ignore see "Why @ts-ignore" note
450
520
expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
@@ -461,13 +531,19 @@ describe('GCPFunction', () => {
461
531
} ;
462
532
const wrappedHandler = wrapCloudEventFunction ( func ) ;
463
533
await expect ( handleCloudEvent ( wrappedHandler ) ) . resolves . toBe ( 42 ) ;
464
- expect ( Sentry . startTransaction ) . toBeCalledWith ( {
534
+
535
+ const fakeTransactionContext = {
465
536
name : 'event.type' ,
466
537
op : 'gcp.function.cloud_event' ,
467
538
metadata : { source : 'component' } ,
468
- } ) ;
539
+ } ;
540
+ // @ts -ignore see "Why @ts-ignore" note
541
+ const fakeTransaction = { ...Sentry . fakeTransaction , ...fakeTransactionContext } ;
542
+
543
+ // @ts -ignore see "Why @ts-ignore" note
544
+ expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
469
545
// @ts -ignore see "Why @ts-ignore" note
470
- expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( Sentry . fakeTransaction ) ;
546
+ expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( fakeTransaction ) ;
471
547
// @ts -ignore see "Why @ts-ignore" note
472
548
expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
473
549
expect ( Sentry . flush ) . toBeCalledWith ( 2000 ) ;
@@ -482,13 +558,19 @@ describe('GCPFunction', () => {
482
558
} ;
483
559
const wrappedHandler = wrapCloudEventFunction ( handler ) ;
484
560
await expect ( handleCloudEvent ( wrappedHandler ) ) . rejects . toThrowError ( error ) ;
485
- expect ( Sentry . startTransaction ) . toBeCalledWith ( {
561
+
562
+ const fakeTransactionContext = {
486
563
name : 'event.type' ,
487
564
op : 'gcp.function.cloud_event' ,
488
565
metadata : { source : 'component' } ,
489
- } ) ;
566
+ } ;
490
567
// @ts -ignore see "Why @ts-ignore" note
491
- expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( Sentry . fakeTransaction ) ;
568
+ const fakeTransaction = { ...Sentry . fakeTransaction , ...fakeTransactionContext } ;
569
+
570
+ // @ts -ignore see "Why @ts-ignore" note
571
+ expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
572
+ // @ts -ignore see "Why @ts-ignore" note
573
+ expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( fakeTransaction ) ;
492
574
expect ( Sentry . captureException ) . toBeCalledWith ( error ) ;
493
575
// @ts -ignore see "Why @ts-ignore" note
494
576
expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
@@ -504,13 +586,20 @@ describe('GCPFunction', () => {
504
586
} ;
505
587
const wrappedHandler = wrapCloudEventFunction ( handler ) ;
506
588
await expect ( handleCloudEvent ( wrappedHandler ) ) . rejects . toThrowError ( error ) ;
507
- expect ( Sentry . startTransaction ) . toBeCalledWith ( {
589
+
590
+ const fakeTransactionContext = {
508
591
name : 'event.type' ,
509
592
op : 'gcp.function.cloud_event' ,
510
593
metadata : { source : 'component' } ,
511
- } ) ;
594
+ } ;
595
+ // @ts -ignore see "Why @ts-ignore" note
596
+ const fakeTransaction = { ...Sentry . fakeTransaction , ...fakeTransactionContext } ;
597
+
598
+ // @ts -ignore see "Why @ts-ignore" note
599
+ expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
512
600
// @ts -ignore see "Why @ts-ignore" note
513
- expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( Sentry . fakeTransaction ) ;
601
+ expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( fakeTransaction ) ;
602
+
514
603
expect ( Sentry . captureException ) . toBeCalledWith ( error ) ;
515
604
} ) ;
516
605
} ) ;
0 commit comments