如何使用 Testcafe 运行 electron inside an alpine docker image?

How to run electron inside an alpine docker image with Testcafe?

我正在尝试 运行 我的电子应用程序 e2e 测试 Testcafe 在 gitlab 上 docker 图像中。

因此我使用 docker image from Testcafe,我只通过安装 yarn.

来扩展它

gitlab 脚本只构建了我的 e2e 测试(成功),但 electron 没有出现,管道因此错误而停止:

$ /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-based 个,但我无法告诉您它们何时可用:https://github.com/DevExpress/testcafe/issues/3100

目前,如果您想将 Electron 与 TestCafe 和 Docker.

一起使用,则可以使用 circleci/node:latest-browsers 并使用 npm 安装 TestCafe