File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -449,6 +449,23 @@ describe("datadog", () => {
449
449
expect ( mockedIncrementInvocations ) . toBeCalledWith ( expect . anything ( ) , mockContext ) ;
450
450
} ) ;
451
451
452
+ it ( "doesn't increment batch item failures if its null" , async ( ) => {
453
+ const lambdaResponse : any = null ;
454
+
455
+ const wrapped = datadog ( async ( ) => {
456
+ return lambdaResponse ;
457
+ } ) ;
458
+
459
+ const lambdaResult = await wrapped ( { } , mockContext , ( ) => { } ) ;
460
+
461
+ expect ( lambdaResult ) . toEqual ( lambdaResponse ) ;
462
+
463
+ expect ( mockedIncrementBatchItemFailures ) . toBeCalledTimes ( 0 ) ;
464
+ expect ( mockedIncrementInvocations ) . toBeCalledTimes ( 1 ) ;
465
+
466
+ expect ( mockedIncrementInvocations ) . toBeCalledWith ( expect . anything ( ) , mockContext ) ;
467
+ } ) ;
468
+
452
469
it ( "doesn't increment errors or invocations with config false setting" , async ( ) => {
453
470
const handlerError : Handler = ( event , context , callback ) => {
454
471
throw Error ( "Some error" ) ;
Original file line number Diff line number Diff line change 1
1
export function isBatchItemFailure ( lambdaResponse : any ) : boolean {
2
2
return (
3
3
typeof lambdaResponse === "object" &&
4
+ lambdaResponse !== null &&
4
5
"batchItemFailures" in lambdaResponse &&
5
6
Array . isArray ( lambdaResponse . batchItemFailures )
6
7
) ;
You can’t perform that action at this time.
0 commit comments