繁体   English   中英

无法在Gitlab.com上的共享运行器上以无头模式运行Puppeteer

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

我在Gitlab.com上建立了一个私人仓库。 我已经为我的代码编写了一些测试用例,包括在浏览器上运行的E2E测试。 为此,我正在使用Puppeteer 我的测试用例是用node.js编写的,我正在使用MochaNyc进行测试和覆盖。

这是我的示例.gitlab-ci.yml文件。

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

更新:现在运行测试时,我在管道构建中收到以下错误:

Failed to launch chrome! spawn chromium ENOENT

浏览器初始化脚本:

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

任何帮助将不胜感激。 问候

谢谢@nurettin。 那位医生无疑对我有很大帮助。 最后,将我的初始化设置为:

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

    });

.gitlab-ci.yml定义的依赖项对我来说.gitlab-ci.yml

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM