Installing and configuring the mabl CLI

Before you start

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

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

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/mabl-cli@latest

Configuration

Using the config command, you can get, set, and list available configuration options, including the browser path, current workspace, and forwarding proxies. To see the full list of configuration opens, run the following command:

# view current configuration keys and values 
> mabl config list

The other possible config arguments include the following:

# set a configuration value
# mabl config set <configuration-key> <value>
> mabl config set workspace <WORKSPACE_ID>

# get a configuration value
# mabl config get <configuration-key>
> mabl config get browser.path

# delete a configuration value
# mabl config delete <configuration-key>
> mabl config delete http.proxy

Proxy Configuration

The mabl CLI supports forwarding 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.

Depending on the type of proxy, you can also add the following configuration settings using mabl config set:

OptionDescriptionDefault value
http.proxyModeSpecify which traffic should use the proxymabl
http.sslVerifyEnable of disable SSL verificationtrue
http.proxyTypeSpecify which proxy implementation to uselegacy

📘

Unset values use the default

If a configuration option is not set, it will appear in the mabl config list table as --- and use the default value(s) which are listed in the previous table.

Similarly, if you remove a proxy config value with the command mabl config delete, the option will appear as unset (---) and use the default values.

http.proxyMode
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.proxyModedescription
mablApplies to mabl traffic only (default setting)
testApplies to test traffic only
allApplies to both mabl and test traffic
noneDo not apply the proxy at all.

👍

Changing the proxy mode

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).

http.sslVerify

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

http.proxyType
There is a known issue with the legacy proxy library that prevents it from honoring the http.sslVerify setting. Instead, it will always verify the SSL certificates, causing errors with proxies that use self-signed certificates. To address this issue, we have added a new proxy implementation with the correct certificate validation behavior. The http.proxyType setting lets you switch between these different proxy implementations. The accepted values are current and legacy (default).

  • current: the proxy library that correctly implements the http.sslVerify flag.
  • legacy: the existing proxy implementation; does not respect the http.sslVerify flag.

Note: We suggest using the current setting in all cases and only falling back to the legacy setting if the current setting does not work with your proxy configuration.

📘

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