Shifting from traditional application testing to serverless TypeScript engineering is all about shifting your perspective: you stop testing a running server, and you start testing how your function responds to events and SDK states. Here is a simple, practical example for each testing, using modern AWS SDK v3 syntax.

1. Unit Testing: Jest + Mock Payloads & SDK Client Mocking

In unit tests, you don't call real AWS services. You pass a simulated API Gateway event to your handler, and you mock the AWS SDK so it returns predictable data instead of hitting live infrastructure.

The Code Under Test (src/handler.ts)

import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';