1
- import { Event } from '@sentry/types' ;
2
1
// 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
3
2
// eslint-disable-next-line import/no-unresolved
4
3
import { Callback , Handler } from 'aws-lambda' ;
@@ -16,9 +15,7 @@ const { wrapHandler } = Sentry.AWSLambda;
16
15
17
16
// Default `timeoutWarningLimit` is 500ms so leaving some space for it to trigger when necessary
18
17
const DEFAULT_EXECUTION_TIME = 100 ;
19
- const fakeEvent = {
20
- fortySix : 'o_O' ,
21
- } ;
18
+ let fakeEvent : { [ key : string ] : unknown } ;
22
19
const fakeContext = {
23
20
callbackWaitsForEmptyEventLoop : false ,
24
21
functionName : 'functionName' ,
@@ -72,6 +69,12 @@ function expectScopeSettings() {
72
69
}
73
70
74
71
describe ( 'AWSLambda' , ( ) => {
72
+ beforeEach ( ( ) => {
73
+ fakeEvent = {
74
+ fortySix : 'o_O' ,
75
+ } ;
76
+ } ) ;
77
+
75
78
afterEach ( ( ) => {
76
79
// @ts -ignore see "Why @ts-ignore" note
77
80
Sentry . resetMocks ( ) ;
@@ -228,9 +231,16 @@ describe('AWSLambda', () => {
228
231
const wrappedHandler = wrapHandler ( handler ) ;
229
232
230
233
try {
234
+ fakeEvent . headers = { 'sentry-trace' : '12312012123120121231201212312012-1121201211212012-0' } ;
231
235
await wrappedHandler ( fakeEvent , fakeContext , fakeCallback ) ;
232
236
} catch ( e ) {
233
- expect ( Sentry . startTransaction ) . toBeCalledWith ( { name : 'functionName' , op : 'awslambda.handler' } ) ;
237
+ expect ( Sentry . startTransaction ) . toBeCalledWith ( {
238
+ name : 'functionName' ,
239
+ op : 'awslambda.handler' ,
240
+ traceId : '12312012123120121231201212312012' ,
241
+ parentSpanId : '1121201211212012' ,
242
+ parentSampled : false ,
243
+ } ) ;
234
244
expectScopeSettings ( ) ;
235
245
expect ( Sentry . captureException ) . toBeCalledWith ( e ) ;
236
246
// @ts -ignore see "Why @ts-ignore" note
0 commit comments