@@ -18,6 +18,7 @@ import {
1818 tracingHandler ,
1919} from '../src/handlers' ;
2020import * as SDK from '../src/sdk' ;
21+ import { setupNodeTransport } from '../src/transports' ;
2122
2223describe ( 'parseRequest' , ( ) => {
2324 let mockReq : { [ key : string ] : any } ;
@@ -223,7 +224,8 @@ describe('requestHandler', () => {
223224 } ) ;
224225
225226 it ( 'autoSessionTracking is enabled, sets requestSession status to ok, when handling a request' , ( ) => {
226- client = new NodeClient ( { autoSessionTracking : true , release : '1.2' } ) ;
227+ const options = { autoSessionTracking : true , release : '1.2' } ;
228+ client = new NodeClient ( options , setupNodeTransport ( options ) . transport ) ;
227229 const hub = new Hub ( client ) ;
228230
229231 jest . spyOn ( sentryCore , 'getCurrentHub' ) . mockReturnValue ( hub ) ;
@@ -235,7 +237,8 @@ describe('requestHandler', () => {
235237 } ) ;
236238
237239 it ( 'autoSessionTracking is disabled, does not set requestSession, when handling a request' , ( ) => {
238- client = new NodeClient ( { autoSessionTracking : false , release : '1.2' } ) ;
240+ const options = { autoSessionTracking : false , release : '1.2' } ;
241+ client = new NodeClient ( options , setupNodeTransport ( options ) . transport ) ;
239242 const hub = new Hub ( client ) ;
240243
241244 jest . spyOn ( sentryCore , 'getCurrentHub' ) . mockReturnValue ( hub ) ;
@@ -247,7 +250,8 @@ describe('requestHandler', () => {
247250 } ) ;
248251
249252 it ( 'autoSessionTracking is enabled, calls _captureRequestSession, on response finish' , done => {
250- client = new NodeClient ( { autoSessionTracking : true , release : '1.2' } ) ;
253+ const options = { autoSessionTracking : true , release : '1.2' } ;
254+ client = new NodeClient ( options , setupNodeTransport ( options ) . transport ) ;
251255 const hub = new Hub ( client ) ;
252256
253257 jest . spyOn ( sentryCore , 'getCurrentHub' ) . mockReturnValue ( hub ) ;
@@ -267,7 +271,8 @@ describe('requestHandler', () => {
267271 } ) ;
268272
269273 it ( 'autoSessionTracking is disabled, does not call _captureRequestSession, on response finish' , done => {
270- client = new NodeClient ( { autoSessionTracking : false , release : '1.2' } ) ;
274+ const options = { autoSessionTracking : false , release : '1.2' } ;
275+ client = new NodeClient ( options , setupNodeTransport ( options ) . transport ) ;
271276 const hub = new Hub ( client ) ;
272277 jest . spyOn ( sentryCore , 'getCurrentHub' ) . mockReturnValue ( hub ) ;
273278
@@ -367,7 +372,8 @@ describe('tracingHandler', () => {
367372
368373 it ( 'extracts request data for sampling context' , ( ) => {
369374 const tracesSampler = jest . fn ( ) ;
370- const hub = new Hub ( new NodeClient ( { tracesSampler } ) ) ;
375+ const options = { tracesSampler } ;
376+ const hub = new Hub ( new NodeClient ( options , setupNodeTransport ( options ) . transport ) ) ;
371377 // we need to mock both of these because the tracing handler relies on `@sentry/core` while the sampler relies on
372378 // `@sentry/hub`, and mocking breaks the link between the two
373379 jest . spyOn ( sentryCore , 'getCurrentHub' ) . mockReturnValue ( hub ) ;
@@ -389,7 +395,8 @@ describe('tracingHandler', () => {
389395 } ) ;
390396
391397 it ( 'puts its transaction on the scope' , ( ) => {
392- const hub = new Hub ( new NodeClient ( { tracesSampleRate : 1.0 } ) ) ;
398+ const options = { tracesSampleRate : 1.0 } ;
399+ const hub = new Hub ( new NodeClient ( options , setupNodeTransport ( options ) . transport ) ) ;
393400 // we need to mock both of these because the tracing handler relies on `@sentry/core` while the sampler relies on
394401 // `@sentry/hub`, and mocking breaks the link between the two
395402 jest . spyOn ( sentryCore , 'getCurrentHub' ) . mockReturnValue ( hub ) ;
@@ -720,7 +727,8 @@ describe('errorHandler()', () => {
720727 jest . restoreAllMocks ( ) ;
721728 } ) ;
722729 it ( 'when autoSessionTracking is disabled, does not set requestSession status on Crash' , ( ) => {
723- client = new NodeClient ( { autoSessionTracking : false , release : '3.3' } ) ;
730+ const options = { autoSessionTracking : false , release : '3.3' } ;
731+ client = new NodeClient ( options , setupNodeTransport ( options ) . transport ) ;
724732 // It is required to initialise SessionFlusher to capture Session Aggregates (it is usually initialised
725733 // by the`requestHandler`)
726734 client . initSessionFlusher ( ) ;
@@ -739,7 +747,8 @@ describe('errorHandler()', () => {
739747 } ) ;
740748
741749 it ( 'autoSessionTracking is enabled + requestHandler is not used -> does not set requestSession status on Crash' , ( ) => {
742- client = new NodeClient ( { autoSessionTracking : false , release : '3.3' } ) ;
750+ const options = { autoSessionTracking : false , release : '3.3' } ;
751+ client = new NodeClient ( options , setupNodeTransport ( options ) . transport ) ;
743752
744753 const scope = sentryCore . getCurrentHub ( ) . getScope ( ) ;
745754 const hub = new Hub ( client ) ;
@@ -755,7 +764,8 @@ describe('errorHandler()', () => {
755764 } ) ;
756765
757766 it ( 'when autoSessionTracking is enabled, should set requestSession status to Crashed when an unhandled error occurs within the bounds of a request' , ( ) => {
758- client = new NodeClient ( { autoSessionTracking : true , release : '1.1' } ) ;
767+ const options = { autoSessionTracking : true , release : '1.1' } ;
768+ client = new NodeClient ( options , setupNodeTransport ( options ) . transport ) ;
759769 // It is required to initialise SessionFlusher to capture Session Aggregates (it is usually initialised
760770 // by the`requestHandler`)
761771 client . initSessionFlusher ( ) ;
@@ -773,7 +783,8 @@ describe('errorHandler()', () => {
773783 } ) ;
774784
775785 it ( 'when autoSessionTracking is enabled, should not set requestSession status on Crash when it occurs outside the bounds of a request' , ( ) => {
776- client = new NodeClient ( { autoSessionTracking : true , release : '2.2' } ) ;
786+ const options = { autoSessionTracking : true , release : '2.2' } ;
787+ client = new NodeClient ( options , setupNodeTransport ( options ) . transport ) ;
777788 // It is required to initialise SessionFlusher to capture Session Aggregates (it is usually initialised
778789 // by the`requestHandler`)
779790 client . initSessionFlusher ( ) ;
0 commit comments