0

I'm using NestJS and would like to run the tests in my Gitlab pipeline, using Jest.

Problem: I get the error sh: 1: jest: not found when I use npm run test

My gitlab-ci.yml

image: node

stages:
  - nest_build
  - nest_test
  - ... my other stages

cache:
  paths:
    - node_modules/

default:
  tags:
    - deploy

nest_build:
  stage: nest_build
  script: 
    - echo "Start building NestJS"
    - npm ci
    - npm run build
    - echo "Build successfully!"
  
nest_test:
  stage: nest_test
  script:
    - echo "Testing NestJS"
    - npm run test
    - echo "Test successfully!"

Pipeline:

$ echo "Testing NestJS"
Testing NestJS
$ npm run test
> skezi-api@0.0.1 test
> jest
sh: 1: jest: not found

My script test in package.json :

"test": "jest",

I tried running npm run test in nest_build and it works fine.

I have a feeling that the node_modules cache is not working?

Alissia
  • 261
  • 1
  • 2
  • 7

0 Answers0