Software Testing is a key part of any application development irrespective of the tools, frameworks or methodologies in use. This simple project is created to put up few examples on how to create Unit tests for Lambda functions using the Jest and other libraries.
Run the following command to run unit tests. For unit testing, update the .env
with AWS region and Lambda Endpoint to local offline endpoint. Refer the sample.env file for the required environment variables.
npm test
For initgration testing, make sure the project is deployed to AWS account. Update the .env
with AWS region and API Gateway Endpoint. Refer the sample.env file for the required environment variables.
npm run test-integration
- Jest Framework - Effortless JavaScript Testing Framework
- Sinon.JS - Easy to create Mocks, Stubs and Spies
- AWS SDK Client Mocks - Easy and powerful mocking of AWS SDK v3 Clients
- Serverless Offline - Emulate AWS λ and API Gateway locally when developing your Serverless project