Hoppscotch CLI
Hoppscotch gives you multiple ways to interact with and configure your APIs. With the command-line interface (CLI) you can interact with the Hoppscotch platform using a terminal, or through an automated system. This enables you to run API tests, manage automated API monitoring, and more.
This section contains a complete list of all Hoppscotch CLI commands available, alongside their optional parameters for additional behavior. You can also find a complete list of configuration options to configure your APIs through Hoppscotch.
- Hoppscotch CLI is currently in alpha. Please report any issues you encounter.
Installing Hoppscotch CLI
To download and install Hoppscotch CLI, run the following command in your terminal:
npm i -g @hoppscotch/cli
Commands
hopp test
The hopp test
command allows you to run tests against a Hoppscotch collection file. This command goes through every request in a collection recursively and runs it, validating the responses with the test script provided in each request.
- The hopp test command recursively goes through each request in the collection and runs them. Hence, the order of execution is the same as the order specified in the collection structure.
- If upon executing the command, a failed assertion (a failing test case) has occurred, the command will give a non-zero exit code and 0 exit code if all tests have passed.
- Unless there was a network error (for e.g, DNS resolution errors, Network Connectivity Issues), the test script will be running and it is up to the test script to define what happens to error status codes. Non-200 status codes are still considered valid responses for test script execution.
hopp test [-e <environment file>] <hoppscotch collection file>
Example
hopp test kitchen-sink-hoppscotch-collection.json
hopp test -e environment.json kitchen-sink-hoppscotch-collection.json
Environment
Hoppscotch allows templates in several places. For example you could specify your endpoint url as <<baseurl>>/post
and specify baseurl as https://echo.hoppscotch.io
in an environment file.
The expected format of an environment file is:
{
"baseurl": "https://echo.hoppscotch.io",
"key2": "value2",
"key3": "value3"
}
Options
Option | Description |
---|---|
-h | Gives a list of associated commands and their descriptions |