M. *_*and 5 automated-tests gitlab testcafe
我正在尝试在gitlab的CI管道中运行端到端测试(使用testcafe)。但是我遇到以下错误:
ERROR The Firefox 52.0.0 / Linux 0.0.0 browser disconnected. This problem may appear when a browser hangs or is closed, or due to network issues.
Run Code Online (Sandbox Code Playgroud)
我的.gitlab-ci.yml如下:
stages:
- test
before_script:
- apt-get update -yqqq
- apt-get install -y xvfb
- apt-get install iceweasel -yqq
- Xvfb :99 -ac &
- export DISPLAY=:99
test-frontend:
image: node:7.7.4
stage: test
script:
- npm install
- npm install -g testcafe@0.19.2
- testcafe --list-browsers
- testcafe firefox e2etests/tests/login.test.js
tags:
- vue
Run Code Online (Sandbox Code Playgroud)
因此,基本上,我将节点docker映像用于测试“阶段”并安装xvfb以“显示”浏览器。
输出ci gitlab:
npm info ok
$ testcafe --list-browsers
Using locally installed version of TestCafe.
firefox
$ testcafe firefox e2etests/tests/login.test.js
Using locally installed version of TestCafe.
Running tests in:
- Firefox 52.0.0 / Linux 0.0.0
Try to
ERROR The Firefox 52.0.0 / Linux 0.0.0 browser disconnected. This problem may appear when a browser hangs or is closed, or due to network issues.
Run Code Online (Sandbox Code Playgroud)
小智 1
要运行 Firefox,还请定义 dbus:
- Xvfb :99 -ac &
- export $(dbus-launch)
Run Code Online (Sandbox Code Playgroud)
更新:
在Xvfb之前添加以下命令:
- apt-get install -y dbus-x11
Run Code Online (Sandbox Code Playgroud)
另外,请尝试以下配置。我已经在 gitlab 上检查过了,它对我来说工作正常:
stages:
- test
before_script:
- apt-get update -yqqq
- apt-get install -yqq xvfb
- apt-get install iceweasel -yqq
- apt-get install dbus-x11 -yqq
- Xvfb :99 -screen 0 1280x720x24 -ac &
- export DISPLAY=:99
- export $(dbus-launch)
test-frontend:
image: node:7.7.4
stage: test
script:
- npm install
- npm install -g testcafe
- testcafe --list-browsers
- testcafe firefox e2etests/tests/login.test.js
tags:
- vue
Run Code Online (Sandbox Code Playgroud)
请参阅此处的完整教程:将 TestCafe 与 GitLab 集成