M
M
mr_blond972021-01-13 09:09:17
Angular
mr_blond97, 2021-01-13 09:09:17

How to fix error when running karma tests for Angular in gitlab CI?

I'm running karma tests for Angular in gitlab CI.

.gitlab-ci.yml:

image: node:14.0.0

cache:
  paths:
    - node_modules/

before_script:
  - npm install
  - apt-get update -qq
  - apt-get install -y -qq rsync
  - apt-get install -y -qq sshpass
  - wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
  - apt install ./google-chrome-stable_current_amd64.deb -y

stages:
  - testing_deploy


build_and_deploy_testing:
  stage: testing_deploy
  script:
    - echo "============== ADD DEVELOP SSH KEY =============="
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
    - echo "============== START BUILD AND DEPLOY TESTING =============="
    - ./node_modules/@angular/cli/bin/ng test --progress false --watch=false


Failed job message:

12 01 2021 16:25:31.828:ERROR [launcher]: Cannot start Chrome
    [2172:2172:0112/162531.552480:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

12 01 2021 16:25:31.829:ERROR [launcher]: Chrome stdout: 
12 01 2021 16:25:31.829:ERROR [launcher]: Chrome stderr: [2172:2172:0112/162531.552480:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

12 01 2021 16:25:31.840:ERROR [launcher]: Chrome failed 2 times (cannot start). Giving up.
Cleaning up file based variables
ERROR: Job failed: exit code 1


How to fix it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
acwartz, 2021-01-13
@acwartz

Set the --no-sandbox key in the launch options of the chrome instance as the error says.

D
Demian Smith, 2021-01-13
@search

Correct karma.config.js:

browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
  ChromeHeadlessNoSandbox: {
    base: 'ChromeHeadless',
    flags: ['--no-sandbox']
  }
},

Here is a discussion of this movement https://github.com/karma-runner/karma-chrome-launc...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question