我们正尝试在gitlab CI作业触发的 BrowserStack 上运行 testcafe 端到端测试。但是,我们看到一个错误:
Error: spawn /home/user/.browserstack/BrowserStackLocal ENOENT
我们遵循的是选项1-使用TestCafe Docker映像 https://devexpress.github.io/testcafe/documentation/continuous-integration/gitlab.html,它将端到端测试作业添加到我们的.gitlab-ci.yml
文件中。我们创建了.base_e2e
作业中使用的e2e_dev
作业库(请参见下文)
我们还使用了testcafe-browser-provider-browserstack
npm依赖,它允许我们的testcafe端到端测试在BrowserStack上执行,如此处https://devexpress.github.io/testcafe/documentation/using-testcafe/common-concepts/browsers/browser-support.html#browsers-in-cloud-testing-services
这是gitlab CI作业错误的副本:
Running with gitlab-runner 11.7.0 (8bb608ff)
on ec2-docker-runner 1c5ac6dc
Using Docker executor with image testcafe/testcafe ...
Pulling docker image testcafe/testcafe ...
Using docker image sha256:f4d0d6abb93c9 for testcafe/testcafe ...
Running on runner-1c5ac6dc-project-7261073-concurrent-0 via ip-10-250-5-194...
Fetching changes...
Removing build/
Removing coverage/
Removing node_modules/
Removing stats.json
HEAD is now at 8574401 Add space before script property
Checking out 8574401c as feature/e2e-on-pipeline...
Skipping Git submodules setup
Downloading artifacts for install_dependencies (150115951)...
Downloading artifacts from coordinator... ok id=150115951 responseStatus=200 OK token=yMPpwZa1
Downloading artifacts for test (150115953)...
Downloading artifacts from coordinator... ok id=150115953 responseStatus=200 OK token=pjsisESV
Downloading artifacts for build_dev (150115954)...
Downloading artifacts from coordinator... ok id=150115954 responseStatus=200 OK token=6hsG8sxx
$ /opt/testcafe/docker/testcafe-docker.sh "browserstack:Chrome@53.0:Windows 10" tests/e2e
Using locally installed version of TestCafe.
Error while trying to execute binary { Error: spawn /home/user/.browserstack/BrowserStackLocal ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)
at onErrorNT (internal/child_process.js:407:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn /home/user/.browserstack/BrowserStackLocal',
path: '/home/user/.browserstack/BrowserStackLocal',
spawnargs:
[ '--daemon',
'start',
'--log-file',
'/dev/null',
'--key',
'nyyp6nnWiL2S6Y7HkvrH',
'--local-identifier',
1548265103368,
'--enable-logging-for-api' ],
cmd:
'/home/user/.browserstack/BrowserStackLocal --daemon start --log-file /dev/null --key nyyp6nnWiL2S6Y7HkvrH --local-identifier 1548265103368 --enable-logging-for-api' }
完整.gitlab-ci.yml
文件
image: node:8-alpine
stages:
- e2e
#############
# Job Bases #
#############
.base_e2e:
stage: e2e
image:
name: testcafe/testcafe
entrypoint: ["/bin/sh", "-c"]
script:
- /opt/testcafe/docker/testcafe-docker.sh "browserstack:Chrome@53.0:Windows 10" tests/e2e
#############
# Jobs #
#############
e2e_dev:
extends: .base_e2e
variables:
ENVIRONMENT: dev
TEST_E2E_APP_URL: https://$ENVIRONMENT.example.com
only:
- /^feature/.*$/
- /^fix/.*$/
- /^bug/.*$/
when: manual
其他信息
当我们运行以下命令yarn时,即yarn test:e2e_pipeline
,将执行端到端测试,并将自动化的视频记录毫无问题地上传到BrowserStack。
"scripts": {
"test:e2e_all": "testcafe 'chrome,firefox' tests/e2e",
"test:e2e_pipeline": "testcafe 'browserstack:Chrome@53.0:Windows 10' tests/e2e"
},
我们的package.json
"devDependencies": {
"testcafe": "^0.23.3",
"testcafe-browser-provider-browserstack": "^1.7.0",
}
答案 0 :(得分:3)
您无需将BrowserStack Local
与官方TestCafe
码头工人镜像一起使用。
TestCafe泊坞窗映像基于alpine:edge
映像。 BrowserStack Local
不支持Alpine Linux
,并且其团队没有计划支持此操作系统。
请在此线程https://github.com/browserstack/browserstack-local-nodejs/issues/32中查看有关它的讨论。解决方法是,您可以尝试根据BrowserStack Local
支持的操作系统构建自己的docker映像。