【问题标题】:codeceptjs tests 'before each' hook error fails to launch chrome. tests were working fine a week agocodeceptjs 测试“在每个”钩子错误无法启动 chrome 之前。一周前测试工作正常
【发布时间】:2020-09-25 14:23:37
【问题描述】:

几个月前我问过这个问题here,但解决方案显然没有帮助,因为我又遇到了完全相同的问题。在那个链接中,我被告知将我的图像从node:latest 更改为node:13。这不再解决问题。我已经尝试了每个版本的节点,但没有一个工作。我曾尝试使用 puppeteer/codeceptjs 的预制图像,但这不起作用。这就是问题所在: 4 个月前,我编写了一堆测试代码。它们工作得很好,所以我在 gitlab 上设置它们来运行自动化测试。 2个月前我遇到了这个问题。我从 node:latest 到 node:13 但截至上周没有运行任何测试。从那时到现在,零行代码发生了变化。在任何测试运行之前,我都会收到以下错误:

smoke tests done by user profile
      "before each" hook: codeceptjs.before for "user creates a new page and inserts a regular 1":
    Failed to launch chrome!
/builds/ameen3/me-cloud-user-tests/node_modules/puppeteer/.local-chromium/linux-706915/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory
TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

现在我到处寻找解决这个问题的方法。我在 codeceptjs 的 GitHub 页面上打开了一个问题,但我没有理由认为他们会提供任何解决方案(他们之前告诉我升级我的 puppeteer 版本,但当我提到我使用的是最新版本时停止响应)。我也发现了这个link,但它对我不起作用,因为它涉及'sudo',这会导致我的 gitlab 管道失败,因为'sudo 不是一个可识别的命令'。那么这就是page。我已经尝试了该页面上的所有解决方案,但没有运气。如果解决方案甚至提到了“纱线”这个词,我的 gitlab.ci-yml 文件就会被标记为无效。我什至创建了一个 package.config 文件并输入了与他们在最佳答案中建议的相同的内容,但它没有用。

我正在使用最新版本的 puppeteer 和最新版本的 codeceptjs。这是直到一周前还在工作的 gitlab.ci-yml 文件

image: node:13


all_tests:
  script:
    - apt-get update && apt-get install -yq libgconf-2-4
    - apt-get update && apt-get install -y wget --no-install-recommends && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && apt-get update && apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst ttf-freefont --no-install-recommends && rm -rf /var/lib/apt/lists/* && apt-get purge --auto-remove -y curl && rm -rf /src/*.deb
    - npm install
    - npm i codeceptjs-puppeteer
    - npm i codeceptjs puppeteer
    - ln -sf ./node_modules/.bin/codeceptjs /usr/local/bin/codeceptjs
    - npm i --save arrify
    - ./node_modules/.bin/codeceptjs run --steps



cache:
  paths:
    - ./node_modules/.bin/codeceptjs
    
after_script:
    - echo "Cleaning up"
    - rm -rf "%CACHE_PATH%/%CI_PIPELINE_ID%" 

这是直到一周前还在工作的配置文件:

exports.config = {
  tests: './tests/test_test.js',
  output: './output',
  helpers: {
    Puppeteer: {
      url: "http://localhost",
      show: false,
      chrome: {
          "args": ["--no-sandbox", "--disable-setuid-sandbox"]
      }
    }
  },
  include: {
    I: './steps_file.js',
    login: './pages/login.js',
    confluence: './pages/confluence.js',
    editor: './pages/editor.js',
  },
  bootstrap: null,
  mocha: {},
  name: 'tests'
};

this 链接(我也尝试过)说要在我的 package.json 文件中添加一些东西。我从未创建过其中之一,因为我从不需要一个来运行测试。现在我已经创建了一个并按照他们的指示测试仍然失败并出现此错误

npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected token p in JSON at position 1 while parsing near 'npm install puppeteer...'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:

所以如果有人可以链接我或向我解释我的 .ci-yml 文件有什么问题。或如何制作一个有效的。甚至他们的工作方式也会很棒。我已经厌倦了处理这个问题,我现在非常讨厌 puppeteer/codeceptjs。但说真的,我该如何让这个 ci-yml 文件正常工作,因为一周前有 0 个问题,现在如果测试在取消前 2 分钟进行,我很幸运。

【问题讨论】:

    标签: docker gitlab puppeteer gitlab-ci codeceptjs


    【解决方案1】:

    您可以尝试在项目文件夹中运行 npm init -y 来创建 package.json 文件。

    【讨论】:

      猜你喜欢
      • 2020-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-24
      • 2020-05-23
      • 2014-06-03
      • 1970-01-01
      相关资源
      最近更新 更多