Logger is not handling missing context
I'm using jest to unit test my project. I'm mocking the event and context and importing my handler which imports lambda-api. When certain tests fail, the lambda-api logger is looking for the context object for a few values and the context object does not exist.
This does not happen in serverless-offline or in deployed functions and I've only seen this issue in my jest unit tests.
I've added the following to the logger.js function (around line 95) and all is fine: context: (context) => { return { remaining: context && context.getRemainingTimeInMillis && context.getRemainingTimeInMillis(), function: context && context.functionName && context.functionName, memory: context && context.memoryLimitInMB && context.memoryLimitInMB, }; },
I need to finish my unit tests, but will probably create a pull-request to get myself around this.
Hey @RWhite-EDR, how are you doing?
Are you planning on creating the PR or shall I take a look and write it? 🙏
@naorpeled All set. Please let me know if you need more details. https://github.com/jeremydaly/lambda-api/pull/267
Hey @RWhite-EDR, I gave this more thought and decided to close this issue and mark it as not planned as this isn't a real use case and should not happen.