Answer the question
In order to leave comments, you need to log in
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
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
Answer the question
In order to leave comments, you need to log in
Set the --no-sandbox key in the launch options of the chrome instance as the error says.
Correct karma.config.js:
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question