Not able to run Puppeteer in headless mode on shared runner on Gitlab.com

Viewed 1328

I have a private repo which I have set up on Gitlab.com . I have written some test cases for my code including E2E tests which runs on browser. For this I am using Puppeteer. My test cases are written in node.js and I am using Mocha and Nyc for testing and coverage part.

Here is my sample .gitlab-ci.yml file.

image: node:10.14.2

cache:
  paths:
  - node_modules/

stages:
  - test

test_async:
  stage: test
  before_script:
   - apt-get update
   - apt-get install -yyq ca-certificates
   - apt-get install -yyq libappindicator1 libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6
   - apt-get install -yyq gconf-service lsb-release wget xdg-utils
   - apt-get install -yyq fonts-liberation

  script:
   - npm install
   - npm i mocha
   - npm i puppeteer
   - npm i nyc
   - npm test

Update : While running the test now I get the following error on my pipeline build :

Failed to launch chrome! spawn chromium ENOENT

Browser initialization script :

browser = await puppeteer.launch({
      headless: true,
      executablePath: 'chromium',
      args: ['--no-sandbox', '--disable-setuid-sandbox'],
      slowMo: 100,
      timeout: 10000
    });

Any help will be appreciated. Regards

1 Answers

Thanks @nurettin . That doc certainly helped me a lot. Finally by setting my initialization as :

browser = await puppeteer.launch({
      headless: true,
      slowMo: 100,
      timeout: 10000,
      args: ['--no-sandbox'],

    });

Did the trick for me along with the dependencies defined in .gitlab-ci.yml .

Related