codeceptjs在'之前进行测试.钩子错误无法启动Chrome.一周前测试工作正常 [英] codeceptjs tests 'before each' hook error fails to launch chrome. tests were working fine a week ago

查看:79
本文介绍了codeceptjs在'之前进行测试.钩子错误无法启动Chrome.一周前测试工作正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几个月前,我问了这个问题

I asked this question several months ago here but the solution was obviously not helpful because here I am again with the exact same problem. in that link I was told to change my image from node:latest to node:13. this no longer fixes the problem. I have tried every version of node and none work. I have tried using premade images of puppeteer/codeceptjs but that does not work. here's the problem: 4 months ago I coded a bunch of tests. they worked fine so i set them up on gitlab to run automated tests. 2 months ago I had that issue. I went from node:latest to node:13 but as of last week NONE of the tests run. ZERO lines of code were changed between then and now. before any test runs I get the following error:

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版本,但是当我提到我使用的是最新版本时就停止了响应).我也发现了这个页面.我已经尝试过该页面上的所有解决方案,但是没有运气.如果解决方案甚至提到了"yarn"一词,我的gitlab.ci-yml文件将被标记为无效.我什至创建了一个package.config文件,并输入了他们在最佳答案中建议的内容,但是没有用.

now I have searched all over the place for solutions to this problem. I opened an issue on codeceptjs' GitHub page but I have no reason to think they will provide any solution (they previously told me to upgrade my puppeteer version but stopped responding when I mentioned I was using the most recent version). I also found this link but it does not work for me because it involves 'sudo' which causes my gitlab pipeline to fail because 'sudo is not a recognized command'. so then there's this page. I have tried all the solutions on that page but with no luck. if the solution even mentions the word 'yarn' my gitlab.ci-yml file is marked as invalid. I even created a package.config file and inputed the same thing as they suggested in the top answer but it didn't work.

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

I am using the most recent version of puppeteer and the most recent version of codeceptjs. this is the gitlab.ci-yml file that was working up until a week ago

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%" 

这是一直运行到一周前的配置文件:

here is the config file which was working until a week ago:

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 link (which I have also tried) says to add some stuff to my package.json file. I never created one of these because I never needed one to run tests. now I have created one and following their instructions the tests still fail with this error

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分钟进行了一次测试.

so if anyone could link me to or explain to me what is wrong with my .ci-yml file. or how to make a working one. or even how they work it would be great. I'm so tired of dealing this issue and I hate puppeteer/codeceptjs with a passion now. but seriously how do I make this ci-yml file to work because a week ago there were 0 issues and now I'm lucky if a test goes 2 minutes before cancelling.

推荐答案

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

You could try running npm init -y inside your project folder to create the package.json file.

这篇关于codeceptjs在'之前进行测试.钩子错误无法启动Chrome.一周前测试工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆