How to Create Powerful Pipelines for React Native in GitLab
How to implement a test pipeline for React Native with GitLab Pipeline: declaring tasks in YML, their dependencies, and fast feedback on every commit.

GitLab Pipeline
GitLab provides DevOps tools, and GitLab Pipeline is one of them. This tool allows you to "build an automation pipeline for continuous integration" that offers fast feedback on commits, branches, or merge requests. Tasks are declared in a YML file with their necessary dependencies, such as specific Docker images.
Creating the Test Pipeline

You need to have an application with tests already integrated before getting started. The .gitlab-ci.yml file should be created in the root folder. A basic example uses Node.js as a base:
image: node:16.10.0
cache:
paths:
- node_modules/
test_async:
script:
- npm install
- node ./specs/start.js ./specs/async.spec.jsTo use Yarn as the dependency manager, add the installation instructions through before_script:
image: node:16.10.0
before_script:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
cache:
paths:
- node_modules/
test_async:
script:
- yarn install
- yarn testImproving the Pipeline

Split into Stages
Organize tasks using the stages key:
stages:
- build-deps
- test
build-deps:
stage: build-deps
script:
- yarn install
run_tests:
stage: test
script:
- yarn testOptimize Execution Time
Implement variables for faster caching:
variables:
FF_USE_FASTZIP: "true"
ARTIFACT_COMPRESSION_LEVEL: "fast"
CACHE_COMPRESSION_LEVEL: "fast"
cache:
- key:
files:
- yarn.lock
paths:
- node_modules/
policy: pull-pushExtract Test Coverage
Use Regex to capture coverage:
run_tests:
stage: test
coverage: '/All\\sfiles\[\\s\]\*\\|\[\\s\]\*(\\d+\\.\\d+)/'
script:
- yarn test:ciConfigure Timezone
In package.json, use cross-env to ensure compatibility:
{
"scripts": {
"test": "cross-env TZ=America/Sao_Paulo jest",
"test:coverage": "cross-env TZ=America/Sao_Paulo jest --coverage --watchAll=false"
},
"devDependencies": {
"cross-env": "^7.0.3"
}
}
Add JUnit Reports
Install jest-junit:
yarn add jest-junit --devConfigure in package.json:
{
"scripts": {
"test:ci": "cross-env TZ=America/Sao_Paulo jest --coverage --watchAll=false --reporters=default --reporters=jest-junit --silent"
}
}And in the pipeline:
run_tests:
stage: test
coverage: '/All\\sfiles\[\\s\]\*\\|\[\\s\]\*(\\d+\\.\\d+)/'
artifacts:
when: always
reports:
junit:
- junit.xml
script:
- yarn test:ci
Final Complete File
image: node:16.10.0
variables:
FF_USE_FASTZIP: "true"
ARTIFACT_COMPRESSION_LEVEL: "fast"
CACHE_COMPRESSION_LEVEL: "fast"
cache:
- key:
files:
- yarn.lock
paths:
- node_modules/
policy: pull-push
- key: yarn-$CI_JOB_IMAGE
paths:
- .yarn
policy: pull-push
before_script:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
stages:
- build-deps
- test
build-deps:
stage: build-deps
script:
- yarn install --cache-folder .yarn
run_tests:
stage: test
coverage: '/All\\sfiles\[\\s\]\*\\|\[\\s\]\*(\\d+\\.\\d+)/'
artifacts:
when: always
reports:
junit:
- junit.xml
script:
- yarn test:ci
Setting a Timeout
Configure the expiration time in CI/CD Settings >> General pipelines >> Timeout to avoid unexpected costs. The example uses 20 minutes.
Conclusion
The article demonstrates how to use GitLab Pipeline to test React Native applications with time optimizations and quality assurance before approving merge requests.
Keep reading
Finally! The Secret of Testing in React Native Revealed
Everything you need to know about automated testing in React Native: why they pay off in reliability, speed and analysis, and how to implement them.
Creating an AI Agent in Claude Code to Control my Smartphone
Automating Android app documentation and testing with an AI agent in Claude Code, wired to an MCP server that drives a real device over ADB.
Creating an AI Agent in Cursor to Interact with GitLab and Shortcut
In the world of agile development, we talk a lot about productivity, automation, and less repetitive work. But in practice, how many times have you wasted time just to open a merge request? Finding the issue context, writing the description, adding links, titles.
This article was translated from Portuguese with the help of an LLM. The original version may contain nuances not fully captured in this translation.