Keploy logo
AWS Lambda logo

Keploy as a AWS Lambda testing framework

Keploy tests AWS Lambda functions by recording a real invocation and every downstream call the handler made, then replaying both as assertions. There is no SAM local container to start, no event JSON to hand-craft, and no deploy needed between changes.

Generate AWS Lambda tests free
keploy record -c "./bootstrap"
18.4K+VS Code1.2M+300M+mocks created

What Keploy gives a AWS Lambda team

Any runtime, any trigger

Keploy records the handler process at the socket layer, so Node, Python, Go, Java, and custom runtimes all record the same way. API Gateway, SQS, and EventBridge triggers are just different event payloads.

  • Node, Python, Go, Java, custom runtimes
  • API Gateway, SQS, and EventBridge events
  • Container image and zip packaging
  • No handler signature change
The problem

Why AWS Lambda integration tests slow teams down

The friction is rarely the assertions. It is everything around them — spinning up dependencies, keeping mocks honest, and repairing tests after every refactor.

Three ways to do it

Testing AWS Lambda: by hand, with SAM local + mocked AWS clients, or with Keploy

SAM local emulates the runtime per invocation and still needs a stub for every AWS call. Keploy records one real invocation and replays the handler with all of them.

Select any row for the full comparison, with code.

Same coverage, three costs

What you write for AWS Lambda vs what Keploy records

All three produce the same assertion. Only the third still passes after the next refactor without anyone editing it.

By hand2–4 hours
handler.test.ts
hand-written
// Hand-written: the event is a fixture, the SDK is stubbed.
import { handler } from '../src/handler';
 
// Copied from the docs once, frozen ever since.
const event = {
requestContext: { http: { method: 'POST' } },
pathParameters: { id: 'ord_1' },
body: JSON.stringify({ paymentToken: 'tok_123' }),
};
 
jest.mock('@aws-sdk/client-dynamodb', () => ({
DynamoDBClient: class {
// Plain object: the real SDK returns typed attribute values.
send = async () => ({ Item: { id: 'ord_1', amount_minor: 4200 } });
},
}));
 
it('confirms an authorized order', async () => {
const res = await handler(event as any);
 
expect(res.statusCode).toBe(200);
});

The event is a frozen fixture and the DynamoDB response skips attribute-value marshalling, so both the trigger contract and the SDK layer go untested.

SAM local + mocked AWS clients1–2 hours
template-invoke.sh
tool-assisted
# SAM local: a container per invocation.
sam build
 
# The event still comes from a generated template, not from reality.
sam local generate-event apigateway http-api-proxy > events/confirm.json
 
# Starts a container that emulates the Lambda runtime each time.
sam local invoke ConfirmOrderFunction --event events/confirm.json
 
# Anything the handler calls still needs LocalStack or a stub.
docker run -d -p 4566:4566 localstack/localstack:3
aws --endpoint-url http://localhost:4566 dynamodb create-table --cli-input-json @table.json

Faithful to the runtime, and every invocation is a container start — plus LocalStack and a table definition for anything the handler touches.

With Keploy~5 minutes
test-1.yaml
auto-generated
# Recorded with: keploy record -c './bootstrap'
# A real invocation. Real event. Real SDK responses.
version: api.keploy.io/v1beta1
kind: Http
name: test-1
spec:
req:
method: POST
url: /orders/ord_1/confirm
header:
# The authoriser context the real trigger supplied.
x-amzn-request-context: "<captured>"
body: '{"paymentToken":"tok_123"}'
resp:
status_code: 200
body:
id: "ord_1"
state: "CONFIRMED"
noise:
- header.x-amzn-requestid
mocks:
- kind: Http
url: https://dynamodb.example.com/
# Typed attribute values, so SDK marshalling runs on replay.
body: '{"Item":{"id":{"S":"ord_1"},"amount_minor":{"N":"4200"}}}'
- kind: Http
url: https://api.payments.example.com/v1/payment_intents/tok_123/confirm

The event carries the real authoriser context and the DynamoDB response keeps its attribute-value encoding, so both layers a fixture skips are exercised.

Times are estimates for authoring one endpoint’s coverage from scratch, not measurements.

Keploy vs the alternatives

AWS Lambda testing tools, compared

The options a team on service and platform integrations actually reaches for, and where each one genuinely wins. Select a row for the full comparison.

Best in classStrongPartialNot covered

Assessments reflect each tool’s documented behaviour, not benchmark measurements.

How it works

Record your AWS Lambda app once, replay it forever

Keploy sits below your AWS Lambda process at the network layer. It watches the calls your app already makes, then serves them back on replay so tests run with no dependencies attached.

Keploy records a GET call to /api/v1/orders/{id} on a AWS Lambda service and captures the dependency calls it makes.

AWS Lambda logo
Your AWS Lambda app
GET/api/v1/orders/{id}200
RecordingKeploy proxyeBPF · userspace
+3 more AWS Lambda dependencies
An example shape of a captured call. Your own endpoints and dependencies come from your real traffic, so nothing here has to be written by hand.
Mock coverage

What Keploy mocks for AWS Lambda, with zero config

6 of the 7 dependencies a typical AWS Lambda service talks to are stubbed from the recording itself — no mock classes, no fixture files, no containers in CI.

Quick start

Your first AWS Lambda test suite in under five minutes

Every command below runs against your existing AWS Lambda service. Nothing in your source tree changes.

  1. 1Install the Keploy CLI

    A single binary. It needs a Linux kernel with eBPF support, or Docker on macOS and Windows — and it adds nothing to your project's dependencies.

    curl -sSL https://keploy.io/install.sh | bash
  2. 2Record your service

    Pass the command you already use to start the app. Keploy runs it and watches every socket it opens.

    keploy record -c "./bootstrap"
  3. 3Exercise the paths you care about

    Invoke the function once through its real trigger. The event it received and every AWS or HTTP call it made are captured together.

    curl -X POST $FUNCTION_URL/orders/ord_1/confirm -H 'Content-Type: application/json' -d '{"paymentToken":"tok_123"}'
  4. 4Replay in CI

    Replay serves the recorded dependency responses, so the job needs no service containers and no Docker daemon.

    keploy test -c "./bootstrap" --delay 6

Ready to try it on your own AWS Lambda service?

FAQ

AWS Lambda testing with Keploy: common questions

Join our GlobalCommunity

Connect with developers worldwide. Follow updates, ask questions, share feedback, and ship faster with other Keploy builders.

1.2M+Installs
18.4K+GitHub
100K+Devs
300M+Mocks
1K+Contributors
#1OSS Trending
4.9★★★★★from 500+ reviews onG2GartnerVS CodeChrome
★★★★★

Best report of integration and API tests I've seen — which we don't get from RestAssured.

G2
★★★★★

Future of microservices testing. I don't write tests now!

G2 · 5/5
★★★★★

An amazing product that simplifies the automation.

Gartner · 4.0
XGitHubSlackYouTubeLinkedIn
Built by developers, for developers.Let's build the future, together.