Tests are most useful when they run automatically — before a deploy, after every commit, or on a schedule. The Hoppscotch CLI runs the same collections and test scripts you build in the app, from a terminal or a CI pipeline, and reports which checks passed.

Install

The CLI is a Node.js package. With a current LTS release of Node.js installed, run:

npm install -g @hoppscotch/cli
hopp --version

If the version prints, you’re ready. The official CLI documentation lists the exact Node.js versions supported by each release and any extra build tools some systems need.

Export what you want to run

  1. In Hoppscotch, open the collection’s menu and export it as JSON, for example shop-api.json.
  2. Export the environment it uses, for example staging.json.
  3. Make sure the requests have tests — see pre-request scripts and tests.

Run a collection

hopp test shop-api.json

With an environment file:

hopp test shop-api.json -e staging.json

The CLI sends each request in order, runs the scripts and prints a summary of passed and failed tests. A delay between requests can be added with -d followed by milliseconds, which helps with rate-limited APIs:

hopp test shop-api.json -e staging.json -d 500

Exit codes make CI simple

When every test passes, the command exits with code 0. If any test fails or a request errors, it exits with a non-zero code. CI systems treat a non-zero exit as a failed step, so a broken API automatically stops the pipeline.

Example: GitHub Actions

name: API tests
on: [push]
jobs:
  api-tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm install -g @hoppscotch/cli
      - run: hopp test tests/shop-api.json -e tests/ci.json

Keep the collection and environment files in the repository, but don’t commit real secrets. Put tokens in your CI system’s secret store and write them into the environment file during the job, or use a separate environment that points to a test server.

Running collections stored in your workspace

Instead of exported files, newer CLI versions can fetch a collection directly from your Hoppscotch workspace using its ID and a personal access token created in your account settings. Self-hosted users also pass their server address. Run hopp test --help to see the options your version supports, such as report output for CI dashboards and running a collection several times with different data.

Troubleshooting

  • hopp: command not found — npm’s global folder isn’t on your PATH. Run npm bin -g or npm prefix -g to find it, or use npx @hoppscotch/cli test ….
  • Variables not replaced — the environment file wasn’t passed with -e, or variable names differ in case.
  • Works in the app, fails in CI — the CI machine may not reach your API (firewall, VPN, localhost address). Point the environment to an address the runner can reach.