Keploy as a Next.js testing framework
Keploy tests Next.js APIs by recording real requests through the running server and every database or outbound call a route handler makes, then replaying both as assertions. Route handlers, middleware, and server actions all execute over a real socket.
keploy record -c "npm run start"What Keploy gives a Next.js team
App Router and Pages Router alike
Keploy runs the production server. Route handlers, API routes, server actions, and middleware all record the same way because capture is at the socket rather than inside the Next runtime.
- Next.js 13 and above
- App Router and Pages Router
- Route handlers and server actions
- Node runtime, not Edge
Why Next.js 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 Next.js: by hand, with Jest + next-test-api-route-handler, or with Keploy
Mocking the database module makes a route pass regardless of whether its query is right. Keploy records the running server, so the real query executes and its rows replay.
Select any row for the full comparison, with code.
What you write for Next.js vs what Keploy records
All three produce the same assertion. Only the third still passes after the next refactor without anyone editing it.
The Prisma mock answers regardless of the query, so a wrong where clause or a missing include passes here and returns nothing in production.
Closer to a real request, and global fetch is replaced wholesale — so every upstream in the handler now returns the same canned body.
The recorded case ran through the real server, so middleware, cookies(), and the actual Prisma query all executed on the way to this response.
Times are estimates for authoring one endpoint’s coverage from scratch, not measurements.
Next.js 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 Next.js app once, replay it forever
Keploy sits below your Next.js 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 Next.js service and captures the dependency calls it makes.
What Keploy mocks for Next.js, with zero config
7 of the 7 dependencies a typical Next.js service talks to are stubbed from the recording itself — no mock classes, no fixture files, no containers in CI.
- Auto-mocked
PostgreSQLView page
Postgres frontend/backend protocol
- Auto-mocked
MySQLView page
MySQL wire protocol
- Auto-mocked
MongoDBView page
MongoDB wire protocol
- Auto-mocked
RedisView page
RESP over TCP
- Auto-mocked
Apache KafkaView page
Kafka producer and consumer protocol
- Auto-mocked
gRPCView page
HTTP/2 framed gRPC calls
- Outbound HTTPAuto-mocked
Outbound HTTP
Any HTTP client call the service makes
Your first Next.js test suite in under five minutes
Every command below runs against your existing Next.js 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 "npm run start"3Exercise the paths you care about
Drive the running server. 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' -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 "npm run start" --delay 12
Ready to try it on your own Next.js service?
Works with the rest of your Next.js stack
Keploy records at the network layer, so framework and driver choices inside your Next.js app do not change how it captures traffic.
Node.js
The runtime page covers driver-level coverage in depth.
TypeScript
Capture is source-agnostic; no transform to configure.
Prisma
Queries record as the Postgres protocol they emit.
PostgreSQL
The database page covers protocol-level capture in depth.
Redis
Route-handler cache reads record in order.
Vercel
Record locally against the production build; replay needs no host.
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 - Languages
Keploy as a TypeScript testing framework
Get integration coverage for a TypeScript service without typed mock factories, casts, or a ts-jest transform.
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 - 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 - Frameworks
Keploy as a NestJS testing framework
Test NestJS controllers through the real HTTP server instead of a Test.createTestingModule graph with every provider mocked.
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
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