-
Notifications
You must be signed in to change notification settings - Fork 204
How to Unit Test Lambda Functions in Local/CI Environment? #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I would be keen to research this! |
Please go for it! 👍 |
@nikhilaravi are you using the |
@nelsonic I read through it yesterday but haven't used it yet. |
@nelsonic what do you think about extending the mock-context-object npm module to generate more accurate responses from the context methods. It doesn't yet account for different invocation types i.e. Event or Request/Response. From the AWS docs about the
|
@nikhilaravi submit this as a question on the project repo and see if you get a response before investing the time in a PR... but if you get a quick response, feel free to extend. We need to check tomorrow if they already have a plan for mocking their Lambda functions... |
@nelsonic okay i'll do that now and I was just thinking about how to mock the function invocation similar to the invoke api but a simple-mock-lambda module sounds great. |
Yeah, I haven't yet seen anything that looks elegant for testing Lambda functions ... we might be forced to come up with something better. 😜 |
All the repos using the mock-context module @nelsonic If we're using promises should we also use an async test runner like ava?
|
Can we simplify it...? |
@nelsonic I had a look at the book you sent us and got a few ideas so will have a go at implementing them on Monday :) |
Sweet! 🍭 |
haha! @nelsonic I found another module that mocks the context https://github.com/motdotla/node-lambda/blob/master/lib/main.js#L51-L67 However the values passed into the 'context.succeed', 'context.fail' methods are not passed back to the invoker. I think the only way to do this at the moment seems to be using the mock-context module (which uses promises) or using callbacks. I have included examples of both in the PR #45 |
Hi @nikhilaravi / @nelsonic , Thank you |
How are we going to Unit Test the Lambda
handler
to ensure it works as expected?https://aws.amazon.com/blogs/compute/serverless-testing-with-aws-lambda/ ?
https://medium.com/@AdamRNeary/developing-and-testing-amazon-lambda-functions-e590fac85df4
The text was updated successfully, but these errors were encountered: