Issue with running tests on GitLab CI/CD Platform

I am setting up a simple node.js application on GitLab

the following is my .gitlab-ci.yml

Specify which docker image to use

We want Node because our app is using Node

image: node:latest

cache:
paths:
- node_modules/
- src/test/

Set the stages for the pipeline

In this configuration, there are 3 stages for our pipeline: build, test, deploy

If we want 2 stages we would put: build, deploy

stages:

  • build
  • test
  • deploy

build_job: # the name of the job, this can be anything
stage: build # the stage for this job set earlier. We manually assign the build stage to the build_stage job
script: # the commands this job is to do.
- echo “Build starting”
- npm install
- echo “NPM install finished.”
artifacts:
paths:
- node_modules/

test_job:
stage: test
script:
- echo “Test starting”
- npm run test
- echo “Test complete!”

deploy_job:
stage: deploy
script:
- echo “Deploy starting”

The pipeline builds fine but the test_job fails as it does not find the tests ( available in src/test )

The same scripts run fine on my local machine

Running with gitlab-runner 13.2.0-rc2 (45f2b4ec)



24Downloading artifacts

00:05

26Downloading artifacts from coordinator… ok id=667310685 responseStatus=200 OK token=jQsk9evs

28Executing “step_script” stage of the job script

00:01

30Test starting

31$ npm run test


33> jest

34No tests found, exiting with code 1

40 testRegex: - 0 matches

43npm ERR! errno 1