Keploy as a NestJS testing framework
Keploy tests NestJS applications by recording real requests through the running HTTP server and every database or outbound call they trigger, then replaying both as assertions. There is no Test.createTestingModule graph to assemble and no provider to override.
keploy record -c "node dist/main.js"What Keploy gives a NestJS team
Any NestJS app, unchanged
Keploy runs the compiled entrypoint. Express and Fastify adapters, microservice transports, and GraphQL resolvers all record the same way because capture happens at the socket rather than inside the DI container.
- NestJS 9 and above
- Express or Fastify adapter
- REST, GraphQL, and gRPC
- Modules initialise for real
Why NestJS 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.
Testing NestJS: by hand, with Jest + createTestingModule, or with Keploy
createTestingModule rebuilds the container with providers swapped out. Keploy records the running app, so guards, interceptors, pipes, and the real provider chain all execute.
Select any row for the full comparison, with code.
What you write for NestJS vs what Keploy records
All three produce the same assertion. Only the third still passes after the next refactor without anyone editing it.
Two casts to any and two hand-written doubles. The auth guard, validation pipe, and response interceptor never run.
Drives the real pipeline — but PaymentsService is overridden, so the one integration this test is named for never actually happens.
The guard authorised this request, the pipe validated the body, and the real PaymentsService made the call — all captured, none overridden.
Times are estimates for authoring one endpoint’s coverage from scratch, not measurements.
NestJS testing tools, compared
The options a team on Node.js actually reaches for, and where each one genuinely wins. Select a row for the full comparison.
Assessments reflect each tool’s documented behaviour, not benchmark measurements.
Record your NestJS app once, replay it forever
Keploy sits below your NestJS 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 NestJS service and captures the dependency calls it makes.
What Keploy mocks for NestJS, with zero config
7 of the 7 dependencies a typical NestJS service talks to are stubbed from the recording itself — no mock classes, no fixture files, no containers in CI.
- Auto-mocked
PostgreSQLView page
Postgres protocol under TypeORM and Prisma
- Auto-mocked
MySQLView page
MySQL protocol under TypeORM and Prisma
- Auto-mocked
MongoDBView page
Wire protocol under Mongoose and the Nest Mongo module
- Auto-mocked
RedisView page
RESP under ioredis and BullMQ
- Auto-mocked
Apache KafkaView page
Kafka protocol under the Nest Kafka transport
- Auto-mocked
gRPCView page
HTTP/2 framed calls from the Nest gRPC transport
- Outbound HTTPAuto-mocked
Outbound HTTP
Any HttpService, axios, or fetch call
Your first NestJS test suite in under five minutes
Every command below runs against your existing NestJS service. Nothing in your source tree changes.
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 | bash2Record your service
Pass the command you already use to start the app. Keploy runs it and watches every socket it opens.
keploy record -c "node dist/main.js"3Exercise the paths you care about
Build as normal, then drive the running app. Every request becomes a test case with its database and HTTP calls captured alongside.
npm run buildcurl -X POST localhost:3000/orders/ord_1/confirm -H 'Content-Type: application/json' -H 'Authorization: Bearer $TOKEN' -d '{"paymentToken":"tok_123"}'4Replay in CI
Replay serves the recorded dependency responses, so the job needs no service containers and no Docker daemon.
keploy test -c "node dist/main.js" --delay 10
Ready to try it on your own NestJS service?
Works with the rest of your NestJS stack
Keploy records at the network layer, so framework and driver choices inside your NestJS app do not change how it captures traffic.
Node.js
The runtime page covers driver-level coverage in depth.
TypeORM
Repository calls record as the SQL they generate.
Prisma
Queries record as the Postgres or MySQL protocol they emit.
PostgreSQL
The database page covers protocol-level capture in depth.
Redis
BullMQ job pushes appear as the Redis exchanges they are.
gRPC
Nest microservice transports captured as HTTP/2 frames.
Testing the rest of your stack
- Languages
Keploy as a Node.js testing framework
Replace nock registrations and in-memory database fixtures with tests recorded from the traffic your Node service already serves.
Read the guide - Databases
Keploy as a PostgreSQL testing framework
Record the Postgres frontend/backend protocol once and replay real result sets in tests — no container, no pg-mem, no schema to rebuild.
Read the guide - Databases
Keploy as a MongoDB testing framework
Mock MongoDB at the wire protocol — real documents, real BSON types, real aggregation results — without a mongod binary in CI.
Read the guide - Caches & Stores
Keploy as a Redis testing framework
Record RESP traffic once and replay real cache hits, misses, TTLs, and pipeline responses without a Redis server in CI.
Read the guide - Cloud & Infra
Keploy as a gRPC testing framework
Record real gRPC exchanges over HTTP/2 and replay them as tests — no in-process stub server, no hand-written mock service implementation.
Read the guide - Frameworks
Keploy as a Express testing framework
Test the whole middleware chain, not a hand-built app instance — Keploy records real requests through your Express router and replays them.
Read the guide
Join our GlobalCommunity
Connect with developers worldwide. Follow updates, ask questions, share feedback, and ship faster with other Keploy builders.
“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