Skill 1.1.7
Write and run unit tests in development environments (for example, using AWS SAM)
Key Concepts
Unit tests should exercise your business logic without calling real AWS services. Keeping the Lambda handler thin and moving logic into plain functions makes this easy, and AWS calls can be replaced with mocks or stubs (for example, moto or botocore.stub.Stubber in Python, or the AWS SDK client mock libraries in JavaScript).
The AWS SAM CLI complements unit tests. sam local invoke runs a function locally in a container that mimics the Lambda runtime, sam local start-api serves your API Gateway endpoints locally, and sam local generate-event produces sample events for services such as S3, SQS and API Gateway to use as test input.