How to set timeout correctly in lambda test mocking

Viewed 11

I developed lambda apps and tested it by using aws-lambda-mock-context. it is like follows. this handler take long time. so that I set context() of timeout:10.

  const ctx = context({timeout:10})


    it("正常登録",async ()=>{
            const event = getRequestParam('ok') as any
            const response = {
                resultStatus: "0",
                transaction: {
                    npTransactionId: "20210700001"
                }
            }
            expect(await handler(event,ctx,()=>{})).toStrictEqual(formatJSONResponse(200,response))
        },10000)})

but when I execute this test. it returned following error. What is the root cause of this? if someone has opinion,will you please let me know. Thanks

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

  ●  Timeout

      25 |
      26 |
    > 27 | const ctx = context({timeout:10})
         |                    ^
      28 |
0 Answers
Related