Skip to main content
Version: 2.0.0

Keploy CLI Commands

Usage

keploy [command] [flags]

You can use --help, -h flag for all the commands to see available flag options and their purpose.

Modes and Flags

Here are some examples of how to use some common flags:

ModeFlags Available
record-c, --command, --config-path, --containerName, -d, --delay, -n, --networkName, --passThroughPorts, -p, --path, --proxyport, --debug
test--apiTimeout, -c, --command, --config-path, --containerName, -d, --delay, --mongoPassword, -n, --networkName, --passThroughPorts, -p, --path, --proxyport, -t, --testsets, --debug
generate-config-p, --path

record

The record mode in Keploy allows the user to record Keploy testcases from the API calls. The recorded testcases and generated mocks are then saved in the keploy directory in the current working directory.

Usage:
keploy record [flags]
Available flags:
  • -c, --command string - Command required to start the user application.

    keploy record --command "node src/app.js"

    In the command above, node src/app.js is the command which starts the user application.

  • --config-path string - Path to the Keploy configuration file. The default is ".".

    keploy record -c "node src/app.js" --config-path "./config-dir/"

    In the above command, config-dir is the directory in the CWD where the Keploy configuration file keploy-config.yaml is stored.

  • --containerName string - Name of the docker container in which the user application is running.

  • -d, --delay uint - Delay in seconds to run user application. The default is 5 seconds.

    keploy record -c "node src/app.js" -d 10
  • - n, --networkName string - Name of the docker network in which the user application is running.

  • --passThroughPorts uints - Ports of outgoing dependency calls to be ignored as mocks and passed through to the actual dependency. The default is no ports.

  • -p, --path string - Path to the local directory where the recorded testcases and generated mocks are to be saved.

    keploy record -c "node src/app.js" -p "./tests"

    In the above command, tests is the directory in the CWD where the recorded testcases and generated mocks are to be stored.

  • --proxyport uint32 - Port to choose to run Keploy as a proxy. The default is 16789.

    keploy record -c "node src/app.js" --proxyport 8080
  • --debug - To start recording testcases with debug mode enabled.

    keploy record -c "node src/app.js" --debug

test

The test mode in Keploy allows the user to run the recoded testcases from the API calls and execute assertion. A detailed report is produced after the tests are executed and it's then saved in the yaml format in keploy/reports directory in the current working directory.

Usage:
keploy test [flags]
Available flags:
  • --apiTimeout uint - Timeout in seconds for calling user application. The default is 5 seconds.

    keploy test -c "node src/app.js" --apiTimeout 10
  • -c, --command string - Command required to start the user application.

    keploy test -c "node src/app.js"

    In the command above, node src/app.js is the command which starts the user application.

  • --config-path string - Path to the Keploy configuration file. The default is ".".

    keploy test -c "node src/app.js" --config-path "./config-dir/"

    In the above command, config-dir is the directory in the CWD where the Keploy configuration file keploy-config.yaml is stored.

  • --containerName string - Name of the docker container in which the user application is running.

  • -d, --delay uint - Delay in seconds to run user application. The default is 5 seconds.

    keploy test -c "node src/app.js" --delay 10
  • --mongoPassword string - Authentication password for mocking MongoDB connection. The default password is "default123".

    keploy test -c "node src/app.js" --mongoPassword "my-password"
  • - n, --networkName string - Name of the docker network in which the user application is running.

  • --passThroughPorts uints - Ports of outgoing dependency calls to be ignored as mocks and passed through to the actual dependency. The default is no ports.

  • -p, --path string - Path to the local directory where the recorded testcases and generated mocks are saved.

    keploy test -c "node src/app.js" -d 10 --path "./tests"

    In the above command, tests is the directory in the CWD where the recorded testcases and generated mocks are saved.

  • --proxyport uint32 - Port to choose to run Keploy as a proxy. The default is 16789.

    keploy test -c "node src/app.js" --proxyport 8080
  • -t, --testsets strings - To specify which specific testsets are to be executed. The default is all testsets.

    keploy test -c "node src/app.js" -t "test-set-1,test-set-3" --delay 10
  • --debug - To start executing testcases with debug mode enabled.

    keploy test -c "node src/app.js" --delay 10 --debug

generate-config

The generate-config command in Keploy is used to generate the Keploy Configuration File i.e. keploy-config.yaml. The generated configuration file is created in the current working directory.

Usage:
keploy generate-config [flags]
Available flags:
  • -p, --path string - Path to the local directory where the Keploy Configuration File will be stored. The default is ".".

    keploy generate-config -p "./config-dir/"

    In the above command, config-dir is the directory in the CWD where the Keploy configuration file keploy-config.yaml is to be stored.

example

The example command in Keploy is designed to illustrate the usage of Keploy in various scenarios, showing its capabilities with different types of applications and setups. Below are examples for using Keploy with Golang, Node.js, Java, and Docker applications.

Usage:
keploy example [flags]
Available Flags:
  • --customSetup - Displays commands tailored for custom user-defined setups.