hoppscotch/packages/hoppscotch-cli
jamesgeorge007 3fc43cc9b9 test: bump timeout
Specify timeout at the CLI e2e test suite level.
2024-11-06 19:22:54 +05:30
..
bin chore: migrate Node.js implementation for js-sandbox to isolated-vm (#3973) 2024-04-19 21:08:46 +05:30
src test: bump timeout 2024-11-06 19:22:54 +05:30
.gitignore Feature: hopp-cli in TypeScript (#2074) 2022-03-28 13:56:15 +05:30
.prettierrc Feature: hopp-cli in TypeScript (#2074) 2022-03-28 13:56:15 +05:30
CONTRIBUTING.md fix: deprecated pnpx usage migrated to pnpm exec 2022-05-03 12:39:56 +05:30
package.json feat: add support for Digest authorization (#4339) 2024-10-29 12:34:40 +05:30
README.md chore: update @hoppscotch/cli README 2024-04-22 21:12:27 +05:30
setupFiles.ts feat(cli): access team workspace collections and environments (#4095) 2024-06-27 18:11:29 +05:30
tsconfig.json feat(cli): add support for JUnit reporter (#4189) 2024-07-26 22:56:58 +05:30
tsup.config.ts chore(cli): emit bundle in ESM format (#3777) 2024-02-05 22:55:05 +05:30
vitest.config.ts feat(cli): access team workspace collections and environments (#4095) 2024-06-27 18:11:29 +05:30

Hoppscotch CLI ALPHA

A CLI to run Hoppscotch Test Scripts in CI environments.

Commands:

  • hopp test [options] [file]: testing hoppscotch collection.json file

Usage:

hopp [options or commands] arguments

Options:

  • -v, --ver: see the current version of the CLI
  • -h, --help: display help for command

Command Descriptions:

  1. hopp -v / hopp --ver

    • Prints out the current version of the Hoppscotch CLI
  2. hopp -h / hopp --help

    • Displays the help text
  3. hopp test [options] <file_path>

    • Interactive CLI to accept Hoppscotch collection JSON path
    • Parses the collection JSON and executes each requests
    • Executes pre-request script.
    • Outputs the response of each request.
    • Executes and outputs test-script response.

    Options:

    -e <file_path> / --env <file_path>
    • Accepts path to env.json with contents in below format:

      {
          "ENV1":"value1",
          "ENV2":"value2"
      }
      
    • You can now access those variables using pw.env.get('<var_name>')

      Taking the above example, pw.env.get("ENV1") will return "value1"

Install

  • Before you install Hoppscotch CLI you need to make sure you have the dependencies it requires to run.

    • Windows & macOS: You will need node-gyp installed. Find instructions here: https://github.com/nodejs/node-gyp
    • Debian/Ubuntu derivatives:
      sudo apt-get install python g++ build-essential
      
    • Alpine Linux:
      sudo apk add python3 make g++
      
    • Amazon Linux (AMI)
      sudo yum install gcc72 gcc72-c++
      
    • Arch Linux
      sudo pacman -S make gcc python
      
    • RHEL/Fedora derivatives:
      sudo dnf install python3 make gcc gcc-c++ zlib-devel brotli-devel openssl-devel libuv-devel
      
  • Once the dependencies are installed, install @hoppscotch/cli from npm by running:

    npm i -g @hoppscotch/cli
    

Developing:

  1. Clone the repository, make sure you've installed latest pnpm.
  2. pnpm install
  3. cd packages/hoppscotch-cli
  4. pnpm run build
  5. sudo pnpm link --global
  6. Test the installation by executing hopp

Contributing:

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a build.
  2. Update the README.md with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters.
  3. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is SemVer.
  4. You may merge the Pull Request once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer merge it for you.

Set Up The Development Environment

  1. After cloning the repository, execute the following commands:

    pnpm install
    pnpm run build
    
  2. In order to test locally, you can use two types of package linking:

    1. The 'pnpm exec' way (preferred since it does not hamper your original installation of the CLI):

      pnpm link @hoppscotch/cli
      
      // Then to use or test the CLI:
      pnpm exec hopp
      
      // After testing, to remove the package linking:
      pnpm rm @hoppscotch/cli
      
    2. The 'global' way (warning: this might override the globally installed CLI, if exists):

      sudo pnpm link --global
      
      // Then to use or test the CLI:
      hopp
      
      // After testing, to remove the package linking:
      sudo pnpm rm --global @hoppscotch/cli
      
  3. To use the Typescript watch scripts:

    pnpm run dev