Skip to main content
View as Markdown

Universal Mocker​

Universal Mocker is Keploy's service virtualization for the tests you already have. You run your own test command under keploy mock record once, with the real dependencies up. Keploy saves every call your tests make to databases, queues and other services, with each answer. After that, keploy mock replay runs the same command with those dependencies switched off and answers each call from the recording.

You write no mock code, and you change no test. Your test framework still decides which tests pass.

Record once against the real dependencies, then replay with them switched off

Understand how it works​

  1. Record. Run keploy mock record -c "<your test command>". Your tests run against the real dependencies. Keploy sits between the two and saves each outgoing call and its answer.

  2. Replay. Run keploy mock replay -c "<your test command>". The dependencies can be off. Keploy answers each call with its recorded answer. By default, a call that matches no recording fails the run (--on-miss fail), so a missing mock never passes silently.

  3. Check every test on its own (optional). With KEPLOY_PROVEN=1, keploy mock record also replays each test with the dependencies off before it keeps the recording. A test that doesn't replay is set aside, with the reason and the next step. See Prove each test offline.

  4. Share. In that mode, when you are signed in, the recordings go to Keploy Cloud, under a Keploy branch named after your git branch. Two things must be true:

    • keploy.yml names a Keploy app (mock.appId). Run keploy app create first, or record once with --app <name>.
    • You record on a git branch other than main. Keploy never publishes to main: switch to a branch first (git switch -c <name>), or pass --branch <name>.

    Your repository holds only keploy.yml and keploy.lock, which pins each test to its recordings. CI replays what keploy.lock pins.

Choose the right Keploy product​

You want to…Use
Run the tests you already have (unit, integration, e2e) without their databases, queues and APIsUniversal Mocker (keploy mock)
Turn real traffic from a running app or a cluster into tests and mocksIntegration Testing (keploy record, k8s-proxy)
Generate API tests from a schema, a collection or live traffic with AIAPI Testing

The difference is who owns the tests. With Universal Mocker, your team owns the tests and records whenever a branch needs it. With Integration Testing, Keploy captures tests from an environment's traffic.

Check what it supports​

Test commands. Any command that runs your tests: go test, pytest, npx jest, mvn test, npx playwright test, or a shell script. Keploy wraps the command and doesn't need to know the framework.

Per-test checks (KEPLOY_PROVEN=1) need each test to say where it starts and ends:

Platforms.

PlatformRecord and replayPer-test checks (KEPLOY_PROVEN=1)Notes
LinuxYesYesKeploy's agent runs as root; Keploy starts it with sudo.
macOS (Apple silicon)YesYesNo sudo or admin rights needed.
DockerYesNot yetPass a docker run or docker compose command.
WindowsComing soonComing soonNative Windows support, VS Code included, is coming.

Dependencies in Keploy 3.9.3. "Docker" means: run the tests through a Docker command so Keploy reads the calls on Linux.

DependencyLinuxmacOS
HTTP and HTTPS, HTTP/2YesYes
gRPCYesYes
PostgreSQLYesYes
MySQLYesYes
MongoDBYesYes
Amazon DynamoDBYesYes
AerospikeYesYes
RedisYesDocker
KafkaYesDocker
MemcachedYesDocker
Apache PulsarYesDocker
Amazon SQSYesDocker
Couchbase, HBase, Apache ZooKeeperYesDocker

A call to any other TCP service is saved as raw bytes. It replays only when your tests send exactly the same bytes again.

Use it from VS Code​

The Keploy VS Code extension installs the Keploy CLI, signs you in, and hands the project setup to your coding agent. Then you record, replay and review from the editor.

Next steps​