1- import { Event } from '@sentry/types' ;
21// 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
32// eslint-disable-next-line import/no-unresolved
43import { Callback , Handler } from 'aws-lambda' ;
@@ -16,9 +15,7 @@ const { wrapHandler } = Sentry.AWSLambda;
1615
1716// Default `timeoutWarningLimit` is 500ms so leaving some space for it to trigger when necessary
1817const DEFAULT_EXECUTION_TIME = 100 ;
19- const fakeEvent = {
20- fortySix : 'o_O' ,
21- } ;
18+ let fakeEvent : { [ key : string ] : unknown } ;
2219const fakeContext = {
2320 callbackWaitsForEmptyEventLoop : false ,
2421 functionName : 'functionName' ,
@@ -72,6 +69,12 @@ function expectScopeSettings() {
7269}
7370
7471describe ( 'AWSLambda' , ( ) => {
72+ beforeEach ( ( ) => {
73+ fakeEvent = {
74+ fortySix : 'o_O' ,
75+ } ;
76+ } ) ;
77+
7578 afterEach ( ( ) => {
7679 // @ts -ignore see "Why @ts-ignore" note
7780 Sentry . resetMocks ( ) ;
@@ -228,9 +231,16 @@ describe('AWSLambda', () => {
228231 const wrappedHandler = wrapHandler ( handler ) ;
229232
230233 try {
234+ fakeEvent . headers = { 'sentry-trace' : '12312012123120121231201212312012-1121201211212012-0' } ;
231235 await wrappedHandler ( fakeEvent , fakeContext , fakeCallback ) ;
232236 } 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+ } ) ;
234244 expectScopeSettings ( ) ;
235245 expect ( Sentry . captureException ) . toBeCalledWith ( e ) ;
236246 // @ts -ignore see "Why @ts-ignore" note
0 commit comments