Installing and configuring the mabl CLI
Installation
To get started, you will need to install Node.js version 14 or higher. If you are using a Mac, we recommend installing Node.js via the Homebrew package manager.
Installation behind a Proxy
If you are behind a corporate firewall and need a proxy to access websites, make sure that npm is configured accordingly before running the command to install the mabl CLI. For example:
npm config set http-proxy http://proxy.example.com:8080
npm config set https-proxy http://proxy.example.com:8080
If you are unsure whether you need proxy settings, please check with your network administrator.
Installing the CLI
With Node.js installed, install the mabl CLI by running the following command in your terminal:
npm i -g @mablhq/mabl-cli
To confirm installation and check the installed version of the CLI, run this command:
mabl --version
Once you install the CLI, you will need to authenticate using either your mabl login credentials or workspace API key. If you are using the CLI on your local machine, you can log in using your mabl credentials:
mabl auth login
Licensing considerations
Authentication using the API key as detailed below is available only to the Enterprise plan users.
On the other hand, if you want to use the mabl CLI as part of your build process, you should authenticate with the API key. To get the API key, go to the mabl app -> Settings -> APIs to copy the key and use with the following command:
mabl auth activate-key <YOUR-API-KEY>
Running tests on your local machine
To run tests locally, including using headless mode, please authenticate with your mabl login credentials since API authentication is only meant for running tests on deployment as part of your CI/CD pipeline.
To check if you are successfully authenticated, run the following command:
$ mabl auth info
> Logged in as user [[email protected]]
> Login expires in [3 hours, 23 minutes]
Updating the CLI tool
To update your version of the mabl CLI tool, run:
npm install -g @mablhq/[email protected]
Configuration
You can get, set, and list available configuration options using the list subcommand. This command can be used to set the current workspace default in the mabl CLI amongst other options.
# view current configuration values
mabl config list
# set a configuration value
mabl config set workspace <WORKSPACE_ID>
# get a configuration value
mabl config get workspace
Proxy Configuration
The mabl CLI supports forward proxies. To use a proxy, set the http.proxy
configuration value to the URL for your proxy server. The URL can contain basic authentication credentials and port information.
If you receive an error that the URL you are specifying is invalid, please confirm that you are using Node.js version 14 or greater.
# add a proxy with no credentials on port 3128
mabl config set http.proxy http://proxy.mycompany.com:3128
# add a proxy using credentials on port 3128
mabl config set http.proxy http://"username:password"@proxy.mycompany.com:3128
# delete the current proxy setting
mabl config delete http.proxy
If you receive a 407
error when logging in, this is a proxy authentication error. Ensure your password and username have been set correctly above.
By default, only mabl-specific requests will go through the forwarding proxy. You can use the http.proxyMode
config flag to specify which traffic to apply the proxy on.
http.proxyMode | description |
---|---|
mabl | Applies to mabl traffic only (default setting) |
test | Applies to test traffic only |
all | Applies to both mabl and test traffic |
none | Do not apply the proxy at all. |
http.proxyMode none
could be useful for testing proxy settings or to turn off a proxy when switching work environments (e.g. office vs. home).
SSL Verification
By default, the CLI verifies server certificates are issued by a known certificate authority. Certificate verification may fail if your proxy is intercepting HTTPS traffic. If you are using a proxy and SSL verification is failing, you can disable certificate verification as shown below. We suggest you do this only if required.
# disable SSL verification
mabl config set http.sslVerify false
# delete the current ssl verification setting to use the default
mabl config delete http.sslVerify
System requirements
- Make sure that you have the Chrome browser installed on your machine.
- Currently, we don't support running the CLI from the Windows Subsystem for Linux (WSL).
Uninstalling the CLI
To remove the mabl CLI, run the following command:
npm remove -g @mablhq/mabl-cli
Updated 9 days ago