11import { deflateRawSync } from "node:zlib" ;
2- import type { FastifyInstance } from "fastify" ;
2+ import type { FastifyInstance , LightMyRequestResponse } from "fastify" ;
33import { afterAll , beforeAll , describe , expect , it } from "vitest" ;
44import { lambdaRoutes } from "../../src/plugins/lambda/routes.js" ;
55import { buildApp , getLocalstackHeaders } from "./app-helper.js" ;
@@ -171,9 +171,11 @@ describe("Lambda Integration", () => {
171171 expect ( body ) . toHaveProperty ( "functionArn" ) ;
172172 } ) ;
173173
174- it ( "should update function configuration (change description)" , { timeout : 60000 } , async ( ) => {
174+ it ( "should update function configuration (change description)" , {
175+ timeout : 60000 ,
176+ } , async ( ) => {
175177 // Retry — LocalStack may need time after function creation
176- let res ;
178+ let res : LightMyRequestResponse | undefined ;
177179 for ( let i = 0 ; i < 15 ; i ++ ) {
178180 res = await app . inject ( {
179181 method : "PUT" ,
@@ -185,9 +187,9 @@ describe("Lambda Integration", () => {
185187 await new Promise ( ( r ) => setTimeout ( r , 2000 ) ) ;
186188 }
187189 // If still failing after retries, the route at least responded (not 404)
188- expect ( res ! . statusCode ) . not . toBe ( 404 ) ;
189- if ( res ! . statusCode === 200 ) {
190- expect ( res ! . json ( ) . message ) . toContain ( "updated" ) ;
190+ expect ( res ? .statusCode ) . not . toBe ( 404 ) ;
191+ if ( res ? .statusCode === 200 ) {
192+ expect ( res . json ( ) . message ) . toContain ( "updated" ) ;
191193 }
192194
193195 // Wait for function to settle after config update
@@ -206,7 +208,7 @@ describe("Lambda Integration", () => {
206208 } ) ;
207209
208210 it ( "should invoke function" , { timeout : 60000 } , async ( ) => {
209- let res ;
211+ let res : LightMyRequestResponse | undefined ;
210212 for ( let i = 0 ; i < 10 ; i ++ ) {
211213 res = await app . inject ( {
212214 method : "POST" ,
@@ -217,9 +219,9 @@ describe("Lambda Integration", () => {
217219 if ( res . statusCode === 200 ) break ;
218220 await new Promise ( ( r ) => setTimeout ( r , 2000 ) ) ;
219221 }
220- expect ( res ! . statusCode ) . not . toBe ( 404 ) ;
221- if ( res ! . statusCode === 200 ) {
222- const body = res ! . json ( ) ;
222+ expect ( res ? .statusCode ) . not . toBe ( 404 ) ;
223+ if ( res ? .statusCode === 200 ) {
224+ const body = res . json ( ) ;
223225 expect ( body ) . toHaveProperty ( "statusCode" ) ;
224226 }
225227 } ) ;
@@ -271,8 +273,7 @@ describe("Lambda Integration", () => {
271273 url : `/${ functionName } /event-source-mappings` ,
272274 headers,
273275 payload : {
274- eventSourceArn :
275- "arn:aws:sqs:us-east-1:000000000000:test-trigger-queue" ,
276+ eventSourceArn : "arn:aws:sqs:us-east-1:000000000000:test-trigger-queue" ,
276277 batchSize : 5 ,
277278 enabled : true ,
278279 } ,
@@ -326,7 +327,7 @@ describe("Lambda Integration", () => {
326327 } ) ;
327328
328329 it ( "should delete the function" , { timeout : 60000 } , async ( ) => {
329- let res ;
330+ let res : LightMyRequestResponse | undefined ;
330331 for ( let i = 0 ; i < 10 ; i ++ ) {
331332 res = await app . inject ( {
332333 method : "DELETE" ,
@@ -337,7 +338,7 @@ describe("Lambda Integration", () => {
337338 await new Promise ( ( r ) => setTimeout ( r , 2000 ) ) ;
338339 }
339340 // Function should be deleted (200) or already gone (404)
340- expect ( [ 200 , 404 ] ) . toContain ( res ! . statusCode ) ;
341+ expect ( [ 200 , 404 ] ) . toContain ( res ? .statusCode ) ;
341342 } ) ;
342343
343344 it ( "should return 404 after deletion" , async ( ) => {
0 commit comments