Hoppscotch CLI is currently in alpha stage. Report a bug by opening a new issue.
Installing Hoppscotch CLI
To download and install Hoppscotch CLI, run the following command in your terminal:The minimum supported Node.js version for the CLI is v18.
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 example, DNS resolution errors or 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.
- The execution of requests within a collection can be deferred using the
-d, --delay
flag. One practical application involves executing requests against APIs with enforced rate limits.
Example
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.
Hoppscotch CLI supports environment files in two specific formats:
1. Single Environment Entry Export Format
This format is generated by Hoppscotch App when you export any of your environment. It includes a named environment (name) with key-value pairs, allowing you to define various variables within a single file.2. Legacy Export Format
Hoppscotch CLI continues to support the legacy format which was previously the only accepted format used by CLI.Please note that the Hoppscotch CLI exclusively supports the above two formats for importing environment variables. It does not offer compatibility with Bulk Environment exports or any other export format.
Options
Option | Description |
---|---|
-h | Gives a list of associated commands and their descriptions |