1
1
import * as sentryCore from '@sentry/core' ;
2
- import * as sentryHub from '@sentry/hub' ;
3
- import { Hub } from '@sentry/hub' ;
2
+ import { Hub , Scope } from '@sentry/core' ;
4
3
import { Transaction } from '@sentry/tracing' ;
5
4
import { Event } from '@sentry/types' ;
6
5
import { SentryError } from '@sentry/utils' ;
@@ -277,10 +276,8 @@ describe('tracingHandler', () => {
277
276
it ( 'puts its transaction on the scope' , ( ) => {
278
277
const options = getDefaultNodeClientOptions ( { tracesSampleRate : 1.0 } ) ;
279
278
const hub = new Hub ( new NodeClient ( options ) ) ;
280
- // we need to mock both of these because the tracing handler relies on `@sentry/core` while the sampler relies on
281
- // `@sentry/hub`, and mocking breaks the link between the two
279
+
282
280
jest . spyOn ( sentryCore , 'getCurrentHub' ) . mockReturnValue ( hub ) ;
283
- jest . spyOn ( sentryHub , 'getCurrentHub' ) . mockReturnValue ( hub ) ;
284
281
285
282
sentryTracingMiddleware ( req , res , next ) ;
286
283
@@ -443,7 +440,6 @@ describe('errorHandler()', () => {
443
440
444
441
jest . spyOn < any , any > ( client , '_captureRequestSession' ) ;
445
442
jest . spyOn ( sentryCore , 'getCurrentHub' ) . mockReturnValue ( hub ) ;
446
- jest . spyOn ( sentryHub , 'getCurrentHub' ) . mockReturnValue ( hub ) ;
447
443
448
444
scope ?. setRequestSession ( { status : 'ok' } ) ;
449
445
sentryErrorMiddleware ( { name : 'error' , message : 'this is an error' } , req , res , next ) ;
@@ -460,7 +456,6 @@ describe('errorHandler()', () => {
460
456
461
457
jest . spyOn < any , any > ( client , '_captureRequestSession' ) ;
462
458
jest . spyOn ( sentryCore , 'getCurrentHub' ) . mockReturnValue ( hub ) ;
463
- jest . spyOn ( sentryHub , 'getCurrentHub' ) . mockReturnValue ( hub ) ;
464
459
465
460
scope ?. setRequestSession ( { status : 'ok' } ) ;
466
461
sentryErrorMiddleware ( { name : 'error' , message : 'this is an error' } , req , res , next ) ;
@@ -474,7 +469,7 @@ describe('errorHandler()', () => {
474
469
// It is required to initialise SessionFlusher to capture Session Aggregates (it is usually initialised
475
470
// by the`requestHandler`)
476
471
client . initSessionFlusher ( ) ;
477
- const scope = new sentryHub . Scope ( ) ;
472
+ const scope = new Scope ( ) ;
478
473
const hub = new Hub ( client , scope ) ;
479
474
480
475
jest . spyOn < any , any > ( client , '_captureRequestSession' ) ;
@@ -493,12 +488,11 @@ describe('errorHandler()', () => {
493
488
// It is required to initialise SessionFlusher to capture Session Aggregates (it is usually initialised
494
489
// by the`requestHandler`)
495
490
client . initSessionFlusher ( ) ;
496
- const scope = new sentryHub . Scope ( ) ;
491
+ const scope = new Scope ( ) ;
497
492
const hub = new Hub ( client , scope ) ;
498
493
499
494
jest . spyOn < any , any > ( client , '_captureRequestSession' ) ;
500
495
jest . spyOn ( sentryCore , 'getCurrentHub' ) . mockReturnValue ( hub ) ;
501
- jest . spyOn ( sentryHub , 'getCurrentHub' ) . mockReturnValue ( hub ) ;
502
496
503
497
sentryErrorMiddleware ( { name : 'error' , message : 'this is an error' } , req , res , next ) ;
504
498
const requestSession = scope ?. getRequestSession ( ) ;
0 commit comments