Next-Gen App & Browser Testing Cloud
Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Efficiently run tests locally using GitLab CI with Docker and platforms like TestMu AI. Learn how to use GitLab CI to run tests locally.
December 28, 2025
Taking over from its predecessor, Jenkins, GitLab CI is a continuous integration/continuous delivery (CI/CD) server. It helps development teams to test code from a centralized location, all while providing built-in integration with Git repositories. In this tutorial, we will be looking at how to use GitLab CI to run tests locally.
Integrate and automate your Selenium test suites with GitLab CI on TestMu AI.
Several times every day, developers send code updates to the Git repository. To reduce the possibility of errors being added to your software, you can create a set of scripts to automatically build and validate your application with any push to the repository. This is nothing more than continuous integration; it automatically and continuously designs and reviews any change contributed to an application, ensuring that the implemented changes satisfy all of the checks, regulations, and code enforcement criteria you have specified for your software.
An example of using Continuous Integration as a method of software development is GitLab itself. There is a collection of scripts for every push to the project where the code is tested against the push.
Features of GitLab CI that help overcoming the testing challenges discussed above
To use GitLab CI, all you need is an application’s base code hosted in a Git repository, and a file called .gitlab-ci.yml, located in the root path of your repository, must be defined for your build, test, and deployment scripts.
You can define the scripts that you want to run in this file, define the include and cache dependencies, pick commands that you want to run in sequence and those in parallel, and determine if you wish to run the scripts automatically or trigger them manually.
When your .gitlab-ci.yml configuration file has been added to your repository, GitLab can detect it and run your scripts with the GitLab Runner app, which functions just like your terminal and substantially helps us reproduce production-like scenarios.
This GitLab Tutorial for beginners and professionals will help you learn how to use GitLab, one of the most popular CI/CD tools used in DevOps.
Although there are varied “Local Testing” concepts that have arisen in recent years, there is only one that developers and testers alike generally embrace. We describe local testing as any test performed on the local machine of a developer and tester. You run the tests locally, whether they be automated or manual, as opposed to externally, i.e., on any hosted server or testing grid, like code development done in the Dev region.
There are advantages to this technique, namely the fact that you can run unit tests efficiently to check the consistency of your code or run manual tests on your app for one-off problems that might occur in development. However, accompanies few challenges to running the tests only locally:
1. Older browser support implies decreased quality.
You may have a few different browsers on your machine, for sure. Chances are, however, that your clients are using browsers that you haven’t downloaded on your local computer. Besides, several individuals might still be using various browser versions to which you do not have access. This likely results in inconsistent results.
2. The same applies to Operating Systems.
All versions of Windows and macOS and their components can not be accounted for by your local machine to ensure that your app runs as intended. A lack of coverage across various combinations of browser / OS means that local-only testing does not guarantee that your software is up to the quality levels anticipated by your users.
3. Still a bottleneck
In an optimistic situation, assume that your local machine is configured to access every browser and operating system accessed by the users. Issue fixed, huh? Not so quickly! Running tests from your local computer, even though you have the coverage, ensures that each of those tests must be performed one at a time, even if they are automated. To delight your customers, you might implement serial testing, but this substantially slows down the speed. And if you work in the CI / CD workflow, you have to wait for your tests to finish before executing the entire build.
4. Challenges in Cloud
Let us say that in a local environment with a reasonably speedy internet connection, the tester is designing and running specific tests, and the tests pass.
Come to Cloud. Now you want to run the tests with the CI framework, which is linked to a test service based on a cloud browser. Cloud-based web testing services will add more complexity for all their ease, as they can be accessed via a business VPN and then depend on the speed and reliability of the test service for the cloud browser. One potential effect of this may be flaky timeout tests due to a latency that has not been applied in the local testing environment.

If there is one thing you can always do, maintain the test suite! In a way, to every bug you patch, add new tests to every new feature.
Only add your .gitlab-ci.yml file to your project, create a new branch, push it, create a Merge Request, and if you like, the CI will kick in, with several parallel jobs. The CI would not let me fail, even though I forgot to run my tests.
However, keeping a CI up and running allows you to pause and maintain your specs. You will often wonder why a test runs on your local computer, but does the CI server continue to fail?
That is why it is super helpful to run the CI docker image locally, to iron out quirks based on the rest of the world.
And by running the GitLab CI Runner itself, you can do just that. It will pick up the .gitlab-ci.yml of your project and run it via Docker locally. So ultimately, any issue you see on the server will undoubtedly happen locally, ensuring good test coverage locally. There are queues of jobs waiting to run with the added advantage that you don’t need to wait in line in case.
The TestMu AI Tunnel allows you to connect your local system with TestMu AI servers via an SSH-based integration Tunnel. Once this Tunnel is established, you can perform local page testing on all 3000+ browser environments present on the platform.
Apologies for throwing a few jargons like Gitlab CI Runner / .gitlab-ci.yml / Docker / Lamba Tunnel ahead of any introduction. But do not worry, the guide is intended to deep dive into several of these strategies to circumvent quirks in running tests locally.
To configure GitLab CI locally, it is essential to understand .gitlab-ci.yml file creation.
The .gitlab-ci.yml file that resides in your repository root is where you configure what your project is doing with CI. It specifies the structures of the pipelines and their order and determines:
Upon any push to your repository, GitLab will scan for a .gitlab-ci.yml file and start jobs on Runner based on the contents of the file.
Because .gitlab-ci.yml is in the repository and is version managed,
In the root directory of your repository, you must create a file called .gitlab-ci.yml. This is a YAML file, so you need to pay special attention to indentation. Always use tabs, not spaces.
A sample .gitlab-ci.yml for a Ruby on Rails project

For most Ruby applications, this is the easiest possible configuration that will work:
Jobs are the fundamental part of the .gitlab-ci.yml file. It specifies job sets with restrictions as to how and when to run them. The jobs are classified as top-level elements with a name (RSpec and RuboCop in this case) and must always contain a keyword – ‘script.’ Jobs are used to build jobs, which are then chosen and executed by Runners within the Runner’s environment.
Each job must run separately from the other.
Each GitLab CI / CD instance has an embedded debug tool that validates the content of your .gitlab-ci.yml files, called the CI Lint tool. Under the ci/lint page in your project namespace, you will find the Lint. HTTPs:/gitlab.example.com/gitlab-org/project-123/-/ci/lint, for example.
For a graphical representation of your .gitlab-ci.yml file, you can use the CI/CD configuration visualization. For more detail and the full .gitlab-ci.yml syntax, please read the reference documentation on .gitlab-ci.yml.
Let’s say you have a .gitlab-ci.yml file, and you want to test this file locally.
Gitlab Runner is the tool to accomplish this! It is an application that works to run jobs in a pipeline with GitLab CI / CD.
Installation:
Install GitLab Runner on the infrastructure you own or control but just make sure that it is installed on a different machine from the one that hosts an instance of GitLab.
GitLab Runner installation is supported by various OS. The following table identifies supporting compatibilities and installation links.
Supported Binaries | x86, AMD64, ARM64, ARM, s390x |
|
|---|---|---|
Linux platforms | CentOS, Debian, Ubuntu, RHEL, Fedora, Mint | |
OS | Linux, Windows, macOS, FreeBSD
| |
Docker Service | It is also possible to run the GitLab Runner within a Docker container or deploy it in a Kubernetes cluster. |
See some best practices on how the GitLab Runner should be used and administered.
Also, we should make sure GitLab Runner should be the same version as GitLab.
Registration:
You need to register individual Runners after installation. When you do so, you establish a communication between your Gitlab instance and the machine which has Runner installed.
Typically, Runners process jobs on the same machine where you installed GitLab Runner. However, you may also have a Runner process job in a container, in a Kubernetes cluster, or in auto-scaled instances in the cloud.
Depending on which OS/platform/binaries Runner is installed, you can refer to the Runner registration guide for registration steps.
Executors:
An Executor decides the environment each job runs in. When a Runner is registered, you must select an executor.
Several Executors supported by Gitlab Runner:
The table below shows the main facts that will help you determine which executor to use with each executor.

Features supported by different Executors:

Of all the choices mentioned above, below could be best opted.
GitLab Runner commands
Below are the set commands used to build, test, register, etc., you would see by giving ‘gitlab-Runner’ without any argument.

The ‘exec’ command is our apple of the eye!
‘gitlab-Runner exec’ command is the command that easily lets you test builds locally.
It allows the jobs specified in .gitlab-ci.yml to run locally! This, in turn, allows for quicker test cycles and makes it easier for broken builds to be patched.
The way it works is, it aims to reproduce the CI Environment as similar as possible to the way it should function. Instead of connecting to GitLab instance, it reads the local .gitlab-ci.yml file and creates a new environment where all the build steps are executed.
Since gitlab-Runner exec clones the current state of the local Git repository, be sure to have committed any changes you want to test beforehand.
The exec command should be executed directly from the root directory because .gitlab-ci.yml is present there. And while executing it, you must specify the executor and the name of the job.
The following instruction, for example, executes a job called ‘test’ locally using a shell executor.
‘gitlab-Runner exec shell tests’
Let us now try to use all the above information to test a change locally!
In order to use Docker, follow the below-mentioned steps:
This will run ‘my-local-job’ defined in the docker container specified in the local .gitlab-ci.yml file.
Note: https://docs.gitlab.com/ee/ci/yaml/README.html : Even though job names are arbitrary, there are specific keywords listed in this link that you cannot use as job names. An excellent link that extensively contains keywords, syntax, and usage.
For best practices on Docker as an executor, go through the document on GitLab Runner with Docker.
Using Shell as an executor on MacOSX:

Basically, in both cases, the gitlab-Runner exec command clones the project from the Gitlab repository, installs all related dependencies, and runs the tests locally!!
This was all about introducing GitLab CI to run tests locally and overcome significant challenges of testing locally otherwise.
The TestMu AI GitLab Integration allows you to create a card directly in your repository from the TestMu AI platform.
Integrate and automate your Selenium test suites with GitLab CI on TestMu AI.
TestMu AI Tunnel App can be used to execute local tests efficiently. This is a confidence booster before deploying any UI change into production because it lets you test your development thoroughly with the Secure Shell(SSH) network protocol hosted by TestMu AI Tunnel. Experience the flexibility to securely test your website on 3000+ browsers and their assorted versions, running on real OS code for cross-platform and cross browser compatibility, even before it gets deployed over the production environment. Before any configurations, download LambdaTunnel for your OS using,

The below .gitlab-ci.yml file would show you how to leverage TestMu AI’s cloud Selenium Grid by performing a browser test through your testing server contained in your GitLab CI build.
// Example of .gitlab-ci.yml for Lambda Tunnel
image: node:7.10
before_script:
- |
cd /builds/qarachit/protractor-selenium-sample-gitlab
wget https://s3.amazonaws.com/lambda-tunnel/LT_Linux.zip
#Extracting tunnel binary
sudo apt-get install unzip
unzip LT_Linux.zip
#Executing tunnel library
./LT -user ${LAMBDATEST_EMAIL} -key ${LAMBDATEST_KEY} &
sleep 30
#Installing Dependencies
echo 'export LT_USERNAME="{your_lambdatest_username}"' >> ~/.bashrc
echo 'export LT_ACCESS_KEY="{your_lambda_access_key}"' >> ~/.bashrc
npm install
npm install -g protractor
job:
script:
#Running Test!
protractor single.conf.js
Once the tunnel is successfully set up, you can start testing in your network by adding the below code.
"desiredCapabilities":
{ "tunnel":true }
While you get TestMu AI Tunnel configured on your suitable machine, if you are working in a team, you could also configure Tunnel to be operated in shared mode!
This removes any overheads arising in shuffling their SSH Tunnel connection across team members to enable access across the team. Maybe a case where a team has, say, seven members, and everyone configured their Tunnel.
Now, a user can only work on a user-specific SSH Tunnel connection. In case you wish to keep a common SSH Tunnel connection across all your teammates, you will need to establish a shared TestMu AI Tunnel that would work for all of the teammates listed under your organization at TestMu AI.
Integrate and automate your Selenium test suites with GitLab CI on TestMu AI.
Kudos!! You now know how to perform local testing by running GitLab CI via Docker successfully. Getting GitLab CI at work or UI-based application using Lambdatest Tunnel is just to ensure how we could integrate spears to execute tests locally, giving us enough confidence as we face production deployment!
If you want to build an automated testing pipeline with GitLab CI/CD & Selenium Grid, TestMu AI can help you do that as well.
Happy Implementations!

Author
Did you find this page helpful?
More Related Hubs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance