首页 > 解决方案 > 如何使用 Testcafe 在高山 docker 映像中运行电子?

问题描述

我正在尝试在 docker 映像内的gitlab上使用 Testcafe为电子应用程序运行我的 e2e 测试。

因此我使用了来自 Testcafe 的 docker 镜像,我只通过安装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

标签: dockertestingelectrontestcafealpine

解决方案


官方的 TestCafe Docker 镜像使用 Alpine 作为基础镜像。Electron 目前不支持 Alpine:https ://github.com/electron/electron/issues/9662#issuecomment-420480342 。我们计划提供更多官方图像,包括基于 Ubuntu 的图像,但我无法告诉您它们何时可用:https ://github.com/DevExpress/testcafe/issues/3100

目前,如果您想将 Electron 与 TestCafe 和 Docker 一起使用,您可以使用circleci/node:latest-browsers并安装 TestCafe 。npm


推荐阅读