When I try to run test with jest I encountered following error.
import context from 'aws-lambda-mock-context'
it("Normal case",async ()=>{
const irohaResponse= registered;
jest.spyOn(IrohaTransactionExec.prototype,"exec").mockReturnValue(Promise.resolve(irohaResponse))
const event = forbidden_shop_request as any
expect(await handler(event,context(),()=>{})).toStrictEqual(response)
},10000)
it seems that mock context() is open in this case.. I would like to root cause an how to fix it. If someone has opinion, will you please let me know . thanks
jest --detectOpenHandles --forceExit
Jest has detected the following 2 open handles potentially keeping Jest from exiting:
● Timeout
30 | jest.spyOn(IrohaTransactionExec.prototype,"exec").mockReturnValue(Promise.resolve(irohaResponse))
31 | const event = forbidden_shop_request as any
> 32 | expect(await handler(event,context(),()=>{})).toStrictEqual(response)
| ^
33 | },10000)
34 | it("Normal case",async ()=>{
35 | const irohaResponse= registered;
at Object.<anonymous>.module.exports (../../../../node_modules/aws-lambda-mock-context/index.js:66:2)
at Object.<anonymous> (test/functions/transactions/handler.spec.ts:32:47)