Gitlab CI / CD中的Puppeteer,无法在Headfull浏览器中进行测试

时间:2020-09-08 11:46:53

标签: docker gitlab puppeteer gitlab-ci

我有一个用于测试主应用程序的puppeteer项目,该项目具有某些依赖可见性的功能,因此必须在headful模式下进行测试。

我希望能够从gitlab启动测试脚本(以便我可以将管道链接到主应用程序),但是似乎我不能强制无头属性设置为true:实际上,当我运行相同的脚本时与healess: true一起使用,它可以工作,而对headless: false则失败。

错误是:

> jest --runInBand
 Error: Failed to launch the browser process!
 Fontconfig warning: "/etc/fonts/fonts.conf", line 100: unknown element "blank"
 [1485:1485:0908/113752.573573:ERROR:browser_main_loop.cc(1512)] Unable to open X display.
 TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md
     at onClose (/builds/tests-puppeteer/node_modules/puppeteer/lib/Launcher.js:750:14)
     at ChildProcess.<anonymous> (/builds/tests-puppeteer/node_modules/puppeteer/lib/Launcher.js:740:61)
     at ChildProcess.emit (events.js:326:22)
     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)

我的jest-puppeteerconfig文件:

module.exports = {
  launch: {
      headless: false,
      slowMo: process.env.SLOWMO ? process.env.SLOWMO : 0,
      devtools: false,
      ignoreHTTPSErrors: true, 
      args: ['--no-sandbox', '--window-size=1920,1040']
  }
}

还有我的.gitlab-CI.yaml

# https://hub.docker.com/r/library/node/tags/
image: node:latest

cache:
  paths:
  - node_modules/

stages:
  - test
  - deploy

Integration_Tests:
  stage: test
  script:
    - apt-get update
    - apt-get install -yq gconf-service 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 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 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
    - npm install
    - npm test
  when: manual
  allow_failure: false
  artifacts:
    paths:
      - public

0 个答案:

没有答案