GitLab Job hangs, doesn’t move to next job for Angular ng test

Last modified date

Comments: 0

Problem

GitLab gets stuck, hangs and doesn’t move on to the next job after running the ng test command in Angular.

This is what the problematic .gitlab-ci.yml file looks like:

test:
  stage: test
  script:
    - npm install
    - ng test

But this doesn’t work because once the tests are complete, the GitLab Runner is left hanging and doesn’t complete, terminate or move on the next job.

Solution

By default, ng test runs in watch mode, which means that it won’t terminate after completing.

So the flag --watch=false needs to be added when running ng test.

test:
  stage: test
  script:
    - npm install
    - ng test --watch=false

Now after running ng test, the GitLab Runner will terminate or move on to the next job once the tests complete/fail etc.

References

https://github.com/angular/angular-cli/issues/978

JakTech

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.