如何使用Testcafe在高山docker图像内运行电子?

问题描述

我正在尝试在docker镜像中的gitlab上使用Testcafe对电子应用运行e2e测试。

因此,我使用的是docker image from Testcafe,仅通过安装yarn即可扩展。

gitlab脚本只是构建了我的e2e测试(成功了),但是电子没有出现,并且管道因以下错误而停止:

$ /opt/testcafe/docker/testcafe-docker.sh electron:./ci ./test/e2e/ --screenshots takeOnFails=true
Using locally installed version of testcafe.
Error: spawn /builds/myFancyProject/node_modules/electron/dist/electron ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processticksAndRejections (internal/process/task_queues.js:84:21)

是否有解决错误的建议?

这是我简单的docker文件

FROM testcafe/testcafe

USER root

RUN apk add --update yarn

解决方法

官方的TestCafe Docker映像使用Alpine作为基础映像。 Electron目前不支持Alpine:https://github.com/electron/electron/issues/9662#issuecomment-420480342。 我们计划提供更多官方映像,包括基于Ubuntu的映像,但我无法提供何时提供这些版本的任何ETA:https://github.com/DevExpress/testcafe/issues/3100

当前,如果要将Electron与TestCafe和Docker一起使用,则可以使用circleci/node:latest-browsers并在npm上安装TestCafe。