codeceptjs在每个钩子错误之前测试无法启动chrome。一周前测试工作正常 [英] codeceptjs tests 'before each' hook error fails to launch chrome. tests were working fine a week ago
问题描述
几个月前我问了这个问题这里,但是该解决方案显然无济于事,因为在这里我仍然遇到完全相同的问题。在该链接中,我被告知将图像从 node:latest
更改为 node:13
。这不再解决问题。我已经尝试了每个版本的节点,但都无法正常工作。我曾尝试使用puppeteer / codeceptjs的预制图像,但这不起作用。问题来了:4个月前,我编写了一些测试代码。他们工作得很好,所以我在gitlab上设置它们以运行自动化测试。 2个月前,我遇到了这个问题。我从node:latest转到node:13,但是截至上周为止,没有任何测试可以运行。从那时到现在,零代码行已更改。在进行任何测试之前,我会收到以下错误消息:
由用户配置文件
$现在,我已经在各地搜索了该问题的解决方案。我在codeceptjs的GitHub页面上打开了一个问题,但我没有理由认为它们会提供任何解决方案(以前他们告诉我升级人偶版本,但在提到我使用最新版本时停止响应)。我也发现了这个链接,但它对我不起作用,因为它涉及导致gitlab管道的'sudo'失败,因为 sudo不能识别的命令。因此,有一个页面。我已经尝试过该页面上的所有解决方案,但是没有运气。如果解决方案甚至提到了 yarn一词,我的gitlab.ci-yml文件将被标记为无效。我什至创建了一个package.config文件,并输入了他们在最佳答案中建议的内容,但是没有用。
进行的每个之前的烟雾测试挂钩:用户创建新页面并插入常规1之前的codeceptjs.before:
无法启动chrome!
/builds/ameen3/me-cloud-user-tests/node_modules/puppeteer/.local-chromium/linux-706915/chrome-linux/chrome:加载共享库时出错:libXss.so.1:无法打开共享对象文件:无此类文件或目录
疑难解答:https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
我使用的是最新版的puppeteer,最新版本的codeceptjs。这是直到一周前仍在工作的gitlab.ci-yml文件
图片:节点:13
all_tests:
脚本:
-易于获取更新&& apt-get install -yq libgconf-2-4
-apt-get更新&& apt-get install -y wget --no-install-recommends&& wget -q -O-https://dl-ssl.google.com/linux/linux_signing_key.pub | apt键添加-&& sh -c’echo deb [arch = amd64] http://dl.google.com/linux/chrome/deb/ stable main >> /etc/apt/sources.list.d/google.list’&& apt-get更新&& apt-get install -y google-chrome-unstable字体-ipafont-哥特式字体-wqy-zenhei字体-泰国-tlwg字体-kacst ttf-freefont --no-install-recommends&& rm -rf / var / lib / apt / lists / *&& apt-get purge-自动删除-y curl&& rm -rf /src/*.deb
-npm install
-npm我codeceptjs-puppeteer
-npm我codeceptjs puppeteer
-ln -sf ./node_modules/.bin/ codeceptjs / usr / local / bin / codeceptjs
-npm i-保存修改
-./node_modules/.bin/codeceptjs run --steps
高速缓存:
路径:
-./node_modules/.bin/codeceptjs
after_script:
-回显清理;
-rm -rf%CACHE_PATH%/%CI_PIPELINE_ID%
以下是一直运行到一周前的配置文件:
exports.config = {
测试: ./ tests / test_test.js,
输出: ./ output,
帮助器:{
Puppeteer:{
url: http:// localhost,
显示:false,
chrome:{
args:[-no -sandbox,-disable-setuid-sandbox]
}
}
},
包括:{
I:'./steps_file.js ',
登录:'./ pages / login.js',
合流:'./ pages / confluence.js',
编辑器:'./ pages / editor.js',
},
引导程序:空,
摩卡:{},
名称: tests
};
此链接(我也尝试过)说要向我的package.json文件添加一些内容。我从来没有创建其中之一,因为我从来不需要运行测试。现在,我已经创建了一个,并按照他们的指示进行测试,但仍然会因该错误而失败
npm ERR! JSON.parse无法解析json
npm ERR! JSON.parse解析 npm install puppeteer ...附近的$ 1 $ JSON中的意外令牌p时
npm错误! JSON.parse无法解析package.json数据。
npm错误! JSON.parse package.json必须是实际的JSON,而不仅仅是JavaScript。
npm错误!可以在以下位置找到此运行的完整日志:
因此,如果有人可以将我链接到我或向我解释什么是错的与我的.ci-yml文件。或如何制作一个。甚至他们的工作方式都很棒。我对解决此问题感到非常厌倦,现在我非常热衷于讨厌puppeteer / codeceptjs。但是认真的我如何使这个ci-yml文件起作用,因为一个星期前有0个问题,现在我很幸运,如果取消前2分钟进行了测试。
解决方案您可以尝试在项目文件夹中运行npm init -y来创建package.json文件。
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
tonode: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
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.
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:
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.
解决方案You could try running npm init -y inside your project folder to create the package.json file.
这篇关于codeceptjs在每个钩子错误之前测试无法启动chrome。一周前测试工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!