With mabl Link, you can run tests against your local environment, including localhost
and 127.0.0.1
, using mabl's secure and scalable cloud infrastructure. One benefit of testing local changes with Link is the ability to run extensive tests in parallel with full diagnostics from mabl cloud runs.
This article explains the configuration steps you need to test localhost with mabl Link.
To test a local environment with mabl Link, the Link Agent should be running on the same machine where the local environment is running. If you haven't already set up the Link Agent, see instructions here.
Add an alias for localhost
mabl Link works by proxying traffic from the browser running in the mabl cloud through the Link Agent to your test environment. Because most browsers have security restrictions that prevent proxying requests to all link-local addresses, you need to use an alias for localhost
to run tests against your local environment.
Docker on OSX already has a built-in alias for localhost. If you're running mabl Link in a Docker container on OSX, skip ahead to the section on updating your mabl environment.
Add an alias for localhost
in the hosts
file of the system where the Link Agent is running:
-
Linux and OSX: edit the
/etc/hosts
file -
Windows: edit the
C:\Windows\System32\Drivers\etc\hosts
The alias should point to the same IP as localhost.
In the hosts
file, look for a line similar to the following:
127.0.0.1 localhost
Add a unique alias to the line, such as link-host
:
127.0.0.1 localhost link-host
Docker on Linux hosts
Testing against localhost
on a Docker container running in Linux requires one extra step: add --net="host"
to the docker run
command. For example:
$ docker run --net="host" mablhq/link-agent --api-key--name
Update your mabl environment
To prepare your mabl environment for testing localhost
, make sure the environment is configured to use mabl Link and update the application URL in your mabl environment to use the new hostname.
For example, If you added an alias called link-host
and your test previously pointed to http://localhost:8080
, update your test to point to http://link-host:8080
.
If you're running Link in Docker on OSX, update the URL in your mabl environment to use host.docker.internal
instead of localhost
. For example, if your URL was http://localhost:3000
, use http://host.docker.internal:3000
instead.