11// NOTE: I have no idea how to fix this right now, and don't want to waste more time, as it builds just fine — Kamil
22// eslint-disable-next-line import/no-unresolved
3+ import * as SentryNode from '@sentry/node' ;
4+ // eslint-disable-next-line import/no-unresolved
35import type { Callback , Handler } from 'aws-lambda' ;
46
57import * as Sentry from '../src' ;
@@ -40,15 +42,15 @@ const fakeCallback: Callback = (err, result) => {
4042
4143function expectScopeSettings ( fakeTransactionContext : any ) {
4244 // @ts -ignore see "Why @ts-ignore" note
43- const fakeTransaction = { ...Sentry . fakeTransaction , ...fakeTransactionContext } ;
45+ const fakeTransaction = { ...SentryNode . fakeTransaction , ...fakeTransactionContext } ;
4446 // @ts -ignore see "Why @ts-ignore" note
45- expect ( Sentry . fakeScope . setSpan ) . toBeCalledWith ( fakeTransaction ) ;
47+ expect ( SentryNode . fakeScope . setSpan ) . toBeCalledWith ( fakeTransaction ) ;
4648 // @ts -ignore see "Why @ts-ignore" note
47- expect ( Sentry . fakeScope . setTag ) . toBeCalledWith ( 'server_name' , expect . anything ( ) ) ;
49+ expect ( SentryNode . fakeScope . setTag ) . toBeCalledWith ( 'server_name' , expect . anything ( ) ) ;
4850 // @ts -ignore see "Why @ts-ignore" note
49- expect ( Sentry . fakeScope . setTag ) . toBeCalledWith ( 'url' , 'awslambda:///functionName' ) ;
51+ expect ( SentryNode . fakeScope . setTag ) . toBeCalledWith ( 'url' , 'awslambda:///functionName' ) ;
5052 // @ts -ignore see "Why @ts-ignore" note
51- expect ( Sentry . fakeScope . setContext ) . toBeCalledWith (
53+ expect ( SentryNode . fakeScope . setContext ) . toBeCalledWith (
5254 'aws.lambda' ,
5355 expect . objectContaining ( {
5456 aws_request_id : 'awsRequestId' ,
@@ -59,7 +61,7 @@ function expectScopeSettings(fakeTransactionContext: any) {
5961 } ) ,
6062 ) ;
6163 // @ts -ignore see "Why @ts-ignore" note
62- expect ( Sentry . fakeScope . setContext ) . toBeCalledWith (
64+ expect ( SentryNode . fakeScope . setContext ) . toBeCalledWith (
6365 'aws.cloudwatch.logs' ,
6466 expect . objectContaining ( {
6567 log_group : 'logGroupName' ,
@@ -77,7 +79,7 @@ describe('AWSLambda', () => {
7779
7880 afterEach ( ( ) => {
7981 // @ts -ignore see "Why @ts-ignore" note
80- Sentry . resetMocks ( ) ;
82+ SentryNode . resetMocks ( ) ;
8183 } ) ;
8284
8385 describe ( 'wrapHandler() options' , ( ) => {
@@ -88,7 +90,7 @@ describe('AWSLambda', () => {
8890 const wrappedHandler = wrapHandler ( handler , { flushTimeout : 1337 } ) ;
8991
9092 await wrappedHandler ( fakeEvent , fakeContext , fakeCallback ) ;
91- expect ( Sentry . flush ) . toBeCalledWith ( 1337 ) ;
93+ expect ( SentryNode . flush ) . toBeCalledWith ( 1337 ) ;
9294 } ) ;
9395
9496 test ( 'captureTimeoutWarning enabled (default)' , async ( ) => {
@@ -104,7 +106,7 @@ describe('AWSLambda', () => {
104106
105107 expect ( Sentry . captureMessage ) . toBeCalled ( ) ;
106108 // @ts -ignore see "Why @ts-ignore" note
107- expect ( Sentry . fakeScope . setTag ) . toBeCalledWith ( 'timeout' , '1s' ) ;
109+ expect ( SentryNode . fakeScope . setTag ) . toBeCalledWith ( 'timeout' , '1s' ) ;
108110 } ) ;
109111
110112 test ( 'captureTimeoutWarning disabled' , async ( ) => {
@@ -152,14 +154,14 @@ describe('AWSLambda', () => {
152154
153155 expect ( Sentry . captureMessage ) . toBeCalled ( ) ;
154156 // @ts -ignore see "Why @ts-ignore" note
155- expect ( Sentry . fakeScope . setTag ) . toBeCalledWith ( 'timeout' , '1m40s' ) ;
157+ expect ( SentryNode . fakeScope . setTag ) . toBeCalledWith ( 'timeout' , '1m40s' ) ;
156158 } ) ;
157159
158160 test ( 'captureAllSettledReasons disabled (default)' , async ( ) => {
159161 const handler = ( ) => Promise . resolve ( [ { status : 'rejected' , reason : new Error ( ) } ] ) ;
160162 const wrappedHandler = wrapHandler ( handler , { flushTimeout : 1337 } ) ;
161163 await wrappedHandler ( fakeEvent , fakeContext , fakeCallback ) ;
162- expect ( Sentry . captureException ) . toBeCalledTimes ( 0 ) ;
164+ expect ( SentryNode . captureException ) . toBeCalledTimes ( 0 ) ;
163165 } ) ;
164166
165167 test ( 'captureAllSettledReasons enable' , async ( ) => {
@@ -173,9 +175,9 @@ describe('AWSLambda', () => {
173175 ] ) ;
174176 const wrappedHandler = wrapHandler ( handler , { flushTimeout : 1337 , captureAllSettledReasons : true } ) ;
175177 await wrappedHandler ( fakeEvent , fakeContext , fakeCallback ) ;
176- expect ( Sentry . captureException ) . toHaveBeenNthCalledWith ( 1 , error ) ;
177- expect ( Sentry . captureException ) . toHaveBeenNthCalledWith ( 2 , error2 ) ;
178- expect ( Sentry . captureException ) . toBeCalledTimes ( 2 ) ;
178+ expect ( SentryNode . captureException ) . toHaveBeenNthCalledWith ( 1 , error ) ;
179+ expect ( SentryNode . captureException ) . toHaveBeenNthCalledWith ( 2 , error2 ) ;
180+ expect ( SentryNode . captureException ) . toBeCalledTimes ( 2 ) ;
179181 } ) ;
180182 } ) ;
181183
@@ -197,11 +199,11 @@ describe('AWSLambda', () => {
197199
198200 expect ( rv ) . toStrictEqual ( 42 ) ;
199201 // @ts -ignore see "Why @ts-ignore" note
200- expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
202+ expect ( SentryNode . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
201203 expectScopeSettings ( fakeTransactionContext ) ;
202204 // @ts -ignore see "Why @ts-ignore" note
203- expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
204- expect ( Sentry . flush ) . toBeCalledWith ( 2000 ) ;
205+ expect ( SentryNode . fakeTransaction . finish ) . toBeCalled ( ) ;
206+ expect ( SentryNode . flush ) . toBeCalledWith ( 2000 ) ;
205207 } ) ;
206208
207209 test ( 'unsuccessful execution' , async ( ) => {
@@ -223,12 +225,12 @@ describe('AWSLambda', () => {
223225 } ;
224226
225227 // @ts -ignore see "Why @ts-ignore" note
226- expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
228+ expect ( SentryNode . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
227229 expectScopeSettings ( fakeTransactionContext ) ;
228- expect ( Sentry . captureException ) . toBeCalledWith ( error ) ;
230+ expect ( SentryNode . captureException ) . toBeCalledWith ( error ) ;
229231 // @ts -ignore see "Why @ts-ignore" note
230- expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
231- expect ( Sentry . flush ) . toBeCalledWith ( 2000 ) ;
232+ expect ( SentryNode . fakeTransaction . finish ) . toBeCalled ( ) ;
233+ expect ( SentryNode . flush ) . toBeCalledWith ( 2000 ) ;
232234 }
233235 } ) ;
234236
@@ -254,7 +256,7 @@ describe('AWSLambda', () => {
254256
255257 const handler : Handler = ( _event , _context , callback ) => {
256258 // @ts -ignore see "Why @ts-ignore" note
257- expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith (
259+ expect ( SentryNode . fakeHub . startTransaction ) . toBeCalledWith (
258260 expect . objectContaining ( {
259261 parentSpanId : '1121201211212012' ,
260262 parentSampled : false ,
@@ -300,12 +302,12 @@ describe('AWSLambda', () => {
300302 } ;
301303
302304 // @ts -ignore see "Why @ts-ignore" note
303- expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
305+ expect ( SentryNode . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
304306 expectScopeSettings ( fakeTransactionContext ) ;
305- expect ( Sentry . captureException ) . toBeCalledWith ( e ) ;
307+ expect ( SentryNode . captureException ) . toBeCalledWith ( e ) ;
306308 // @ts -ignore see "Why @ts-ignore" note
307- expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
308- expect ( Sentry . flush ) . toBeCalled ( ) ;
309+ expect ( SentryNode . fakeTransaction . finish ) . toBeCalled ( ) ;
310+ expect ( SentryNode . flush ) . toBeCalled ( ) ;
309311 }
310312 } ) ;
311313 } ) ;
@@ -328,11 +330,11 @@ describe('AWSLambda', () => {
328330
329331 expect ( rv ) . toStrictEqual ( 42 ) ;
330332 // @ts -ignore see "Why @ts-ignore" note
331- expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
333+ expect ( SentryNode . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
332334 expectScopeSettings ( fakeTransactionContext ) ;
333335 // @ts -ignore see "Why @ts-ignore" note
334- expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
335- expect ( Sentry . flush ) . toBeCalled ( ) ;
336+ expect ( SentryNode . fakeTransaction . finish ) . toBeCalled ( ) ;
337+ expect ( SentryNode . flush ) . toBeCalled ( ) ;
336338 } ) ;
337339
338340 test ( 'event and context are correctly passed to the original handler' , async ( ) => {
@@ -365,12 +367,12 @@ describe('AWSLambda', () => {
365367 } ;
366368
367369 // @ts -ignore see "Why @ts-ignore" note
368- expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
370+ expect ( SentryNode . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
369371 expectScopeSettings ( fakeTransactionContext ) ;
370- expect ( Sentry . captureException ) . toBeCalledWith ( error ) ;
372+ expect ( SentryNode . captureException ) . toBeCalledWith ( error ) ;
371373 // @ts -ignore see "Why @ts-ignore" note
372- expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
373- expect ( Sentry . flush ) . toBeCalled ( ) ;
374+ expect ( SentryNode . fakeTransaction . finish ) . toBeCalled ( ) ;
375+ expect ( SentryNode . flush ) . toBeCalled ( ) ;
374376 }
375377 } ) ;
376378
@@ -408,11 +410,11 @@ describe('AWSLambda', () => {
408410
409411 expect ( rv ) . toStrictEqual ( 42 ) ;
410412 // @ts -ignore see "Why @ts-ignore" note
411- expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
413+ expect ( SentryNode . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
412414 expectScopeSettings ( fakeTransactionContext ) ;
413415 // @ts -ignore see "Why @ts-ignore" note
414- expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
415- expect ( Sentry . flush ) . toBeCalled ( ) ;
416+ expect ( SentryNode . fakeTransaction . finish ) . toBeCalled ( ) ;
417+ expect ( SentryNode . flush ) . toBeCalled ( ) ;
416418 } ) ;
417419
418420 test ( 'event and context are correctly passed to the original handler' , async ( ) => {
@@ -445,12 +447,12 @@ describe('AWSLambda', () => {
445447 } ;
446448
447449 // @ts -ignore see "Why @ts-ignore" note
448- expect ( Sentry . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
450+ expect ( SentryNode . fakeHub . startTransaction ) . toBeCalledWith ( fakeTransactionContext ) ;
449451 expectScopeSettings ( fakeTransactionContext ) ;
450- expect ( Sentry . captureException ) . toBeCalledWith ( error ) ;
452+ expect ( SentryNode . captureException ) . toBeCalledWith ( error ) ;
451453 // @ts -ignore see "Why @ts-ignore" note
452- expect ( Sentry . fakeTransaction . finish ) . toBeCalled ( ) ;
453- expect ( Sentry . flush ) . toBeCalled ( ) ;
454+ expect ( SentryNode . fakeTransaction . finish ) . toBeCalled ( ) ;
455+ expect ( SentryNode . flush ) . toBeCalled ( ) ;
454456 }
455457 } ) ;
456458 } ) ;
0 commit comments