Skip to Content
Learn AWS Serverless Computing
book

Learn AWS Serverless Computing

by Scott Patterson
December 2019
Intermediate to advanced
382 pages
9h 43m
English
Packt Publishing
Content preview from Learn AWS Serverless Computing

Unit testing lambda functions

Unit tests are the fundamental beginnings of making sure our function's functions are behaving the way they're expected to. They are really good to run quickly and often. If you're following TDD, unit tests can even help guide you to only write the functionality you need.

Before launching our options for unit testing plugins, let's not forget the most basic way to test our lambda function using the framework, that is, the sls invoke command. We can use the framework to run our function locally, emulating the Lambda environment. The following commands show how we can do this. You can test this on your own function as well:

sls invoke local --function hello

If we had some input data to inject into the event object, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Practical Amazon EC2, SQS, Kinesis, and S3: A Hands-On Approach to AWS

Practical Amazon EC2, SQS, Kinesis, and S3: A Hands-On Approach to AWS

Sunil Gulabani

Publisher Resources

ISBN: 9781789958355