What would be the best way to improve this Gitlab CI/CD (Gitlab.com) pipeline's efficiency and consistency?
Can you explain the reason for why the &quot;step_script&quot; installs the dependencies and not use a prebuild images that has all the dependencies installed?
Solution
Based on the information you provided, Your test infrastucture rebuild even the test container from scratch.
You tests take a long time to be done as those lines indicate also a fresh composing of the docker container:

(1/11) Installing ca-certificates (20191127-r2) 
(2/11) Installing nghttp2-libs (1.40.0-r1) 
(3/11) Installing libcurl (7.67.0-r3) 
(4/11) Installing expat (2.2.9-r1) 
(5/11) Installing pcre2 (10.34-r1) 
(6/11) Installing git (2.24.3-r0) 
(7/11) Installing c-ares (1.15.0-r0) 
(8/11) Installing libgcc (9.3.0-r0) 
(9/11) Installing libstdc++ (9.3.0-r0) 
(10/11) Installing nodejs (12.20.1-r0) 
(11/11) Installing yarn (1.19.2-r0)

If you build a docker image with those thing preinstalled, your Tests will run much faster.
This Process creates clean environment where the only change to it will be the code that has changed!!
The new Docker image then need to be only pulled ones and can be reused.
Build/test infra
docker run -v &quot;$(pwd)&quot;/target:/app:ro -name BUILDID jdalrymple/docker-compose-with-node yarn test
run that for each of your tests.