Skip to main content
Version: 2.0.0

Introduction

This is a sample app to test Keploy integration capabilities using Bun.js and MongoDB.

🛠️ Platform-Specific Requirements for Keploy

Below is a table summarizing the tools needed for both native and Docker installations of Keploy on MacOS, Windows, and Linux:

Operating SystemWithout DockerDocker InstallationPrerequisites
MacOS MacOSNot SupportedSupportedDocker Desktop version must be 4.25.2 or above
Windows WindowsSupportedSupported- Use WSL wsl --install
- Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11
Linux LinuxSupportedSupportedLinux kernel 5.15 or higher

On MacOS and Windows, additional tools are required for Keploy due to the lack of native eBPF support.

Quick Installation

Let's get started by setting up the Keploy alias with this command:

 curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh

You should see something like this:

       ▓██▓▄
▓▓▓▓██▓█▓▄
████████▓▒
▀▓▓███▄ ▄▄ ▄ ▌
▄▌▌▓▓████▄ ██ ▓█▀ ▄▌▀▄ ▓▓▌▄ ▓█ ▄▌▓▓▌▄ ▌▌ ▓
▓█████████▌▓▓ ██▓█▄ ▓█▄▓▓ ▐█▌ ██ ▓█ █▌ ██ █▌ █▓
▓▓▓▓▀▀▀▀▓▓▓▓▓▓▌ ██ █▓ ▓▌▄▄ ▐█▓▄▓█▀ █▓█ ▀█▄▄█▀ █▓█
▓▌ ▐█▌ █▌


Keploy CLI

Available Commands:
example Example to record and test via keploy
generate-config generate the keploy configuration file
record record the keploy testcases from the API calls
test run the recorded testcases and execute assertions
update Update Keploy

Flags:
--debug Run in debug mode
-h, --help help for keploy
-v, --version version for keploy

Use "keploy [command] --help" for more information about a command.

🎉 Wohoo! You are all set to use Keploy.

Get Started! 🎬

Clone a sample user data CRUD app 🧪

git clone https://github.com/keploy/samples-typescript && cd samples-typescript/bun-mongo

# Install the dependencies

bun install

Installation Keploy

Depending on your OS, choose your adventure:

There are 2 ways you can run this sample application.

Using Docker Compose 🐳

We will be using Docker compose to run the application as well as Postgres on Docker container.

Lights, Camera, Record! 🎥

Start DB Instance

Start the db instance using the docker-compose file-

docker compose up mongo

Change the database configuration in django_postgres/settings.py file to:

Since we have setup our sample-app natively, we need to update the mongoDB host on line 43, in supabun.ts, from mongodb://mongoDb-bun:27017/keploy to mongodb://localhost:27017/keploy.

Build the app image:

docker build -t bunApp:1.0 .

Capture the test-cases-

keploy record -c "docker run -p 4200:4200 --name bunMongoApp --network keploy-network bun-app:1.0"

🔥Make some API calls. Postman, Hoppscotch or even curl - take your pick!

Let's make URLs short and sweet:

Generate testcases

To generate testcases we just need to make some API calls.

1. Make a POST request

curl --request POST localhost:4200/save

2. Make a GET request

curl --request GET localhost:4200/fetch

3. Make a PUT request

curl --location --request PUT 'http://127.0.0.1:8000/user/efbe12df-3cae-4cbc-b045-dc74840aa82b/' \
--header 'Content-Type: application/json' \
--data-raw ' {
"name": "Jane Smith",
"email": "smith.jane@example.com",
"password": "smith567",
"website": "www.smithjane.com"
}'

4. Make a GET request

curl --location 'http://127.0.0.1:8000/user/c793c752-ad95-4cff-8cbe-5715a1e8a76e/'

Give yourself a pat on the back! With that simple spell, you've conjured up a test case with a mock! Explore the Keploy directory and you'll discover your handiwork in test-1.yml and mocks.yml.

version: api.keploy.io/v1beta1
kind: Http
name: test-1
spec:
metadata: {}
req:
method: POST
proto_major: 1
proto_minor: 1
url: http://localhost:4200/save
header:
Accept: "*/*"
Host: localhost:4200
User-Agent: curl/8.2.1
body: ""
timestamp: 2024-02-24T11:16:49.156825536Z
resp:
status_code: 200
header:
Access-Control-Allow-Credentials: "true"
Access-Control-Allow-Headers: "*"
Access-Control-Allow-Methods: POST
Access-Control-Allow-Origin: "*"
Access-Control-Exposed-Headers: "*"
Content-Length: "16"
Content-Type: application/json;charset=utf-8
Date: Sat, 24 Feb 2024 11:16:49 GMT
Vary: "*"
body: '{"success":true}'
status_message: OK
proto_major: 0
proto_minor: 0
timestamp: 2024-02-24T11:16:51.280382177Z
objects: []
assertions:
noise:
header.Date: []
created: 1708773411
curl: |
curl --request POST \
--url http://localhost:4200/save \
--header 'User-Agent: curl/8.2.1' \
--header 'Accept: */*' \
--header 'Host: localhost:4200' \

This is how mocks.yml generated would look like:-

 version: api.keploy.io/v1beta1
kind: Mongo
name: mock-0
spec:
metadata:
operation: '{ OpQuery flags: [], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "nodejs|Mongoose","version": "5.9.1|7.6.8"},"platform": "Bun v1.0.29, LE","os": {"name": "linux","architecture": "x64","version": "6.5.0-17-generic","type": "Linux"}},"compression": ["none"]}, returnFieldsSelector: }'
type: config
requests:
- header:
length: 298
requestId: 1
responseTo: 0
Opcode: 2004
message:
flags: 0
collection_name: admin.$cmd
number_to_skip: 0
number_to_return: -1
query: '{"ismaster":{"$numberInt":"1"},"helloOk":true,"client":{"driver":{"name":"nodejs|Mongoose","version":"5.9.1|7.6.8"},"platform":"Bun v1.0.29, LE","os":{"name":"linux","architecture":"x64","version":"6.5.0-17-generic","type":"Linux"}},"compression":["none"]}'
return_fields_selector: ""
responses:
- header:
length: 329
requestId: 3
responseTo: 1
Opcode: 1
message:
response_flags: 8
cursor_id: 0
starting_from: 0
number_returned: 1
documents:
- '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"65d9cff2df019fd437739fbf"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1708773364196"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"1"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}}'
read_delay: 623599
created: 1708773364
reqTimestampMock: 2024-02-24T11:16:04.196109922Z
resTimestampMock: 2024-02-24T11:16:04.197231354Z
---
version: api.keploy.io/v1beta1
kind: Mongo
name: mock-1
spec:
metadata:
operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"create":"animals","lsid":{"id":{"$binary":{"base64":"zOPs0UhFTzaDZlU+iad5xg==","subType":"04"}}},"$db":"keploy"} }], checksum: 0 }'
requests:
- header:
length: 98
requestId: 3
responseTo: 0
Opcode: 2013
message:
flagBits: 0
sections:
- '{ SectionSingle msg: {"create":"animals","lsid":{"id":{"$binary":{"base64":"zOPs0UhFTzaDZlU+iad5xg==","subType":"04"}}},"$db":"keploy"} }'
checksum: 0
read_delay: 6520498
responses:
- header:
length: 38
requestId: 5
responseTo: 3
Opcode: 2013
message:
flagBits: 0
sections:
- '{ SectionSingle msg: {"ok":{"$numberDouble":"1.0"}} }'
checksum: 0
read_delay: 602253
created: 1708773364
reqTimestampMock: 2024-02-24T11:16:04.254900776Z
resTimestampMock: 2024-02-24T11:16:04.25581579Z
---
version: api.keploy.io/v1beta1
kind: Mongo
name: mock-2
spec:
metadata:
operation: '{ OpMsg flags: 65536, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"maxAwaitTimeMS":{"$numberInt":"10000"},"topologyVersion":{"processId":{"$oid":"65d9cff2df019fd437739fbf"},"counter":{"$numberLong":"0"}},"$db":"admin"} }], checksum: 0 }'
type: config
requests:
- header:
length: 134
requestId: 4
responseTo: 0
Opcode: 2013
message:
flagBits: 65536
sections:
- '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"maxAwaitTimeMS":{"$numberInt":"10000"},"topologyVersion":{"processId":{"$oid":"65d9cff2df019fd437739fbf"},"counter":{"$numberLong":"0"}},"$db":"admin"} }'
checksum: 0
read_delay: 531789033
responses:
- header:
length: 313
requestId: 6
responseTo: 4
Opcode: 2013
message:
flagBits: 2
sections:
- '{ SectionSingle msg: {"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"65d9cff2df019fd437739fbf"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1708773374735"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"1"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }'
checksum: 0
read_delay: 10006875186
created: 1708773374
reqTimestampMock: 2024-02-24T11:16:04.728966188Z
resTimestampMock: 2024-02-24T11:16:14.736354258Z
---
version: api.keploy.io/v1beta1
kind: Mongo
name: mock-3
spec:
metadata:
operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"$db":"admin"} }], checksum: 0 }'
type: config
requests:
- header:
length: 55
requestId: 6
responseTo: 0
Opcode: 2013
message:
flagBits: 0
sections:
- '{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"$db":"admin"} }'
checksum: 0
read_delay: 10013801234
responses:
- header:
length: 304
requestId: 9
responseTo: 6
Opcode: 2013
message:
flagBits: 0
sections:
- '{ SectionSingle msg: {"ismaster":true,"topologyVersion":{"processId":{"$oid":"65d9cff2df019fd437739fbf"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1708773384750"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"3"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }'
checksum: 0
read_delay: 361888
created: 1708773384
reqTimestampMock: 2024-02-24T11:16:24.750477084Z
resTimestampMock: 2024-02-24T11:16:24.751206134Z
---
version: api.keploy.io/v1beta1
kind: Mongo
name: mock-4
spec:
metadata:
operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"insert":"animals","documents":[{"name":"Cow","sound":"Moo","_id":{"$oid":"65d9d02107882a00d23b5ac0"},"__v":{"$numberInt":"0"}}],"ordered":true,"lsid":{"id":{"$binary":{"base64":"zOPs0UhFTzaDZlU+iad5xg==","subType":"04"}}},"$db":"keploy"} }], checksum: 0 }'
requests:
- header:
length: 187
requestId: 9
responseTo: 0
Opcode: 2013
message:
flagBits: 0
sections:
- '{ SectionSingle msg: {"insert":"animals","documents":[{"name":"Cow","sound":"Moo","_id":{"$oid":"65d9d02107882a00d23b5ac0"},"__v":{"$numberInt":"0"}}],"ordered":true,"lsid":{"id":{"$binary":{"base64":"zOPs0UhFTzaDZlU+iad5xg==","subType":"04"}}},"$db":"keploy"} }'
checksum: 0
read_delay: 44940206029
responses:
- header:
length: 45
requestId: 14
responseTo: 9
Opcode: 2013
message:
flagBits: 0
sections:
- '{ SectionSingle msg: {"n":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }'
checksum: 0
read_delay: 4726351
created: 1708773409
reqTimestampMock: 2024-02-24T11:16:49.196056727Z
resTimestampMock: 2024-02-24T11:16:49.201252579Z
---
version: api.keploy.io/v1beta1
kind: Mongo
name: mock-5
spec:
metadata:
operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"animals","filter":{"name":"Cow"},"limit":{"$numberInt":"1"},"singleBatch":true,"batchSize":{"$numberInt":"1"},"lsid":{"id":{"$binary":{"base64":"zOPs0UhFTzaDZlU+iad5xg==","subType":"04"}}},"$db":"keploy"} }], checksum: 0 }'
requests:
- header:
length: 163
requestId: 11
responseTo: 0
Opcode: 2013
message:
flagBits: 0
sections:
- '{ SectionSingle msg: {"find":"animals","filter":{"name":"Cow"},"limit":{"$numberInt":"1"},"singleBatch":true,"batchSize":{"$numberInt":"1"},"lsid":{"id":{"$binary":{"base64":"zOPs0UhFTzaDZlU+iad5xg==","subType":"04"}}},"$db":"keploy"} }'
checksum: 0
read_delay: 8924817543
responses:
- header:
length: 166
requestId: 17
responseTo: 11
Opcode: 2013
message:
flagBits: 0
sections:
- '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":{"$oid":"65d9cd7b1052611b2d2aaf42"},"name":"Cow","sound":"Moo","__v":{"$numberInt":"0"}}],"id":{"$numberLong":"0"},"ns":"keploy.animals"},"ok":{"$numberDouble":"1.0"}} }'
checksum: 0
read_delay: 574025
created: 1708773418
reqTimestampMock: 2024-02-24T11:16:58.126078397Z
resTimestampMock: 2024-02-24T11:16:58.127001556Z

Want to see if everything works as expected?

Run Tests

Time to put things to the test 🧪

keploy test -c "docker run -p 4200:4200 --name bunMongoApp --network keploy-network bun-app:1.0"

The --delay flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking.

Final thoughts? Dive deeper! Try different API calls, tweak the DB response in the mocks.yml, or fiddle with the request or response in test-x.yml. Run the tests again and see the magic unfold!✨👩‍💻👨‍💻✨

Wrapping it up 🎉

Congrats on the journey so far! You've seen Keploy's power, flexed your coding muscles, and had a bit of fun too! Now, go out there and keep exploring, innovating, and creating! Remember, with the right tools and a sprinkle of fun, anything's possible.😊🚀

Happy coding! ✨👩‍💻👨‍💻✨

**********************************___**********************************

Running App Locally on Linux/WSL 🐧

We'll be running our sample application right on Linux, but just to make things a tad more thrilling, we'll have the database (MongoDB) chill on Docker. Ready? Let's get the party started!🎉

📼 Roll the Tape - Recording Time!

To install the dependencies

bun install

Using the docker-compose file we will start our Postgres instance:-

docker compose up mongo

Ready, set, record! Here's how:

sudo -E env PATH=$PATH Keploy record -c 'bun run supabun.ts'

Keep an eye out for the -c flag! It's the command charm to run the app.

Alright, magician! With the app alive and kicking, let's weave some test cases. The spell? Making some API calls! Postman, Hoppscotch, or the classic curl - pick your wand.

Generate testcases

To generate testcases we just need to make some API calls.

1. Make a POST request

curl --request POST localhost:4200/save

2. Make a GET request

curl --request GET localhost:4200/fetch

Give yourself a pat on the back! With that simple spell, you've conjured up a test case with a mock! Explore the Keploy directory and you'll discover your handiwork in test-1.yml and mocks.yml.

version: api.keploy.io/v1beta1
kind: Http
name: test-1
spec:
metadata: {}
req:
method: POST
proto_major: 1
proto_minor: 1
url: http://localhost:4200/save
header:
Accept: "*/*"
Host: localhost:4200
User-Agent: curl/8.2.1
body: ""
timestamp: 2024-02-24T11:16:49.156825536Z
resp:
status_code: 200
header:
Access-Control-Allow-Credentials: "true"
Access-Control-Allow-Headers: "*"
Access-Control-Allow-Methods: POST
Access-Control-Allow-Origin: "*"
Access-Control-Exposed-Headers: "*"
Content-Length: "16"
Content-Type: application/json;charset=utf-8
Date: Sat, 24 Feb 2024 11:16:49 GMT
Vary: "*"
body: '{"success":true}'
status_message: OK
proto_major: 0
proto_minor: 0
timestamp: 2024-02-24T11:16:51.280382177Z
objects: []
assertions:
noise:
header.Date: []
created: 1708773411
curl: |
curl --request POST \
--url http://localhost:4200/save \
--header 'User-Agent: curl/8.2.1' \
--header 'Accept: */*' \
--header 'Host: localhost:4200' \


```yaml
---
version: api.keploy.io/v1beta1
kind: Mongo
name: mock-0
spec:
metadata:
operation: '{ OpQuery flags: [], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "nodejs|Mongoose","version": "5.9.1|7.6.8"},"platform": "Bun v1.0.29, LE","os": {"name": "linux","architecture": "x64","version": "6.5.0-17-generic","type": "Linux"}},"compression": ["none"]}, returnFieldsSelector: }'
type: config
requests:
- header:
length: 298
requestId: 1
responseTo: 0
Opcode: 2004
message:
flags: 0
collection_name: admin.$cmd
number_to_skip: 0
number_to_return: -1
query: '{"ismaster":{"$numberInt":"1"},"helloOk":true,"client":{"driver":{"name":"nodejs|Mongoose","version":"5.9.1|7.6.8"},"platform":"Bun v1.0.29, LE","os":{"name":"linux","architecture":"x64","version":"6.5.0-17-generic","type":"Linux"}},"compression":["none"]}'
return_fields_selector: ""
responses:
- header:
length: 329
requestId: 3
responseTo: 1
Opcode: 1
message:
response_flags: 8
cursor_id: 0
starting_from: 0
number_returned: 1
documents:
- '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"65d9cff2df019fd437739fbf"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1708773364196"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"1"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}}'
read_delay: 623599
created: 1708773364
reqTimestampMock: 2024-02-24T11:16:04.196109922Z
resTimestampMock: 2024-02-24T11:16:04.197231354Z
---
version: api.keploy.io/v1beta1
kind: Mongo
name: mock-1
spec:
metadata:
operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"create":"animals","lsid":{"id":{"$binary":{"base64":"zOPs0UhFTzaDZlU+iad5xg==","subType":"04"}}},"$db":"keploy"} }], checksum: 0 }'
requests:
- header:
length: 98
requestId: 3
responseTo: 0
Opcode: 2013
message:
flagBits: 0
sections:
- '{ SectionSingle msg: {"create":"animals","lsid":{"id":{"$binary":{"base64":"zOPs0UhFTzaDZlU+iad5xg==","subType":"04"}}},"$db":"keploy"} }'
checksum: 0
read_delay: 6520498
responses:
- header:
length: 38
requestId: 5
responseTo: 3
Opcode: 2013
message:
flagBits: 0
sections:
- '{ SectionSingle msg: {"ok":{"$numberDouble":"1.0"}} }'
checksum: 0
read_delay: 602253
created: 1708773364
reqTimestampMock: 2024-02-24T11:16:04.254900776Z
resTimestampMock: 2024-02-24T11:16:04.25581579Z
---
version: api.keploy.io/v1beta1
kind: Mongo
name: mock-2
spec:
metadata:
operation: '{ OpMsg flags: 65536, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"maxAwaitTimeMS":{"$numberInt":"10000"},"topologyVersion":{"processId":{"$oid":"65d9cff2df019fd437739fbf"},"counter":{"$numberLong":"0"}},"$db":"admin"} }], checksum: 0 }'
type: config
requests:
- header:
length: 134
requestId: 4
responseTo: 0
Opcode: 2013
message:
flagBits: 65536
sections:
- '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"maxAwaitTimeMS":{"$numberInt":"10000"},"topologyVersion":{"processId":{"$oid":"65d9cff2df019fd437739fbf"},"counter":{"$numberLong":"0"}},"$db":"admin"} }'
checksum: 0
read_delay: 531789033
responses:
- header:
length: 313
requestId: 6
responseTo: 4
Opcode: 2013
message:
flagBits: 2
sections:
- '{ SectionSingle msg: {"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"65d9cff2df019fd437739fbf"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1708773374735"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"1"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }'
checksum: 0
read_delay: 10006875186
created: 1708773374
reqTimestampMock: 2024-02-24T11:16:04.728966188Z
resTimestampMock: 2024-02-24T11:16:14.736354258Z
---
version: api.keploy.io/v1beta1
kind: Mongo
name: mock-3
spec:
metadata:
operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"$db":"admin"} }], checksum: 0 }'
type: config
requests:
- header:
length: 55
requestId: 6
responseTo: 0
Opcode: 2013
message:
flagBits: 0
sections:
- '{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"$db":"admin"} }'
checksum: 0
read_delay: 10013801234
responses:
- header:
length: 304
requestId: 9
responseTo: 6
Opcode: 2013
message:
flagBits: 0
sections:
- '{ SectionSingle msg: {"ismaster":true,"topologyVersion":{"processId":{"$oid":"65d9cff2df019fd437739fbf"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1708773384750"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"3"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }'
checksum: 0
read_delay: 361888
created: 1708773384
reqTimestampMock: 2024-02-24T11:16:24.750477084Z
resTimestampMock: 2024-02-24T11:16:24.751206134Z
---
version: api.keploy.io/v1beta1
kind: Mongo
name: mock-4
spec:
metadata:
operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"insert":"animals","documents":[{"name":"Cow","sound":"Moo","_id":{"$oid":"65d9d02107882a00d23b5ac0"},"__v":{"$numberInt":"0"}}],"ordered":true,"lsid":{"id":{"$binary":{"base64":"zOPs0UhFTzaDZlU+iad5xg==","subType":"04"}}},"$db":"keploy"} }], checksum: 0 }'
requests:
- header:
length: 187
requestId: 9
responseTo: 0
Opcode: 2013
message:
flagBits: 0
sections:
- '{ SectionSingle msg: {"insert":"animals","documents":[{"name":"Cow","sound":"Moo","_id":{"$oid":"65d9d02107882a00d23b5ac0"},"__v":{"$numberInt":"0"}}],"ordered":true,"lsid":{"id":{"$binary":{"base64":"zOPs0UhFTzaDZlU+iad5xg==","subType":"04"}}},"$db":"keploy"} }'
checksum: 0
read_delay: 44940206029
responses:
- header:
length: 45
requestId: 14
responseTo: 9
Opcode: 2013
message:
flagBits: 0
sections:
- '{ SectionSingle msg: {"n":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }'
checksum: 0
read_delay: 4726351
created: 1708773409
reqTimestampMock: 2024-02-24T11:16:49.196056727Z
resTimestampMock: 2024-02-24T11:16:49.201252579Z
---
version: api.keploy.io/v1beta1
kind: Mongo
name: mock-5
spec:
metadata:
operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"animals","filter":{"name":"Cow"},"limit":{"$numberInt":"1"},"singleBatch":true,"batchSize":{"$numberInt":"1"},"lsid":{"id":{"$binary":{"base64":"zOPs0UhFTzaDZlU+iad5xg==","subType":"04"}}},"$db":"keploy"} }], checksum: 0 }'
requests:
- header:
length: 163
requestId: 11
responseTo: 0
Opcode: 2013
message:
flagBits: 0
sections:
- '{ SectionSingle msg: {"find":"animals","filter":{"name":"Cow"},"limit":{"$numberInt":"1"},"singleBatch":true,"batchSize":{"$numberInt":"1"},"lsid":{"id":{"$binary":{"base64":"zOPs0UhFTzaDZlU+iad5xg==","subType":"04"}}},"$db":"keploy"} }'
checksum: 0
read_delay: 8924817543
responses:
- header:
length: 166
requestId: 17
responseTo: 11
Opcode: 2013
message:
flagBits: 0
sections:
- '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":{"$oid":"65d9cd7b1052611b2d2aaf42"},"name":"Cow","sound":"Moo","__v":{"$numberInt":"0"}}],"id":{"$numberLong":"0"},"ns":"keploy.animals"},"ok":{"$numberDouble":"1.0"}} }'
checksum: 0
read_delay: 574025
created: 1708773418
reqTimestampMock: 2024-02-24T11:16:58.126078397Z
resTimestampMock: 2024-02-24T11:16:58.127001556Z

Want to see if everything works as expected?

Run Tests

Time to put things to the test 🧪

sudo -E env PATH=$PATH keploy test -c 'bun run supabun.ts'

The --delay flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking.

Final thoughts? Dive deeper! Try different API calls, tweak the DB response in the mocks.yml, or fiddle with the request or response in test-x.yml. Run the tests again and see the magic unfold!✨👩‍💻👨‍💻✨

Wrapping it up 🎉

Congrats on the journey so far! You've seen Keploy's power, flexed your coding muscles, and had a bit of fun too! Now, go out there and keep exploring, innovating, and creating! Remember, with the right tools and a sprinkle of fun, anything's possible. 😊🚀

Happy coding! ✨👩‍💻👨‍💻✨