在无头容器中使用 electron 发布 运行 testcafe
Issue running testcafe with electron in a headless container
我正在尝试 运行 在 debian docker 容器上以无头模式使用 testcafe-browser-provider-electron 进行 testcafe。
我不断收到
testcafe:browser-provider-electron:spawn:stderr [122:0520/185130.933152:FATAL:atom_main_delegate.cc(211)] Running as root without --no-sandbox is not supported.
See https://crbug.com/63818ERROR Was unable to open the browser "electron:./app" due to error.
我已经在 npx 中以及通过本地安装的 testcafe 中尝试 运行ning。
Docker 文件
FROM node:13.4.0-buster AS builder
ENV DEBIAN_FRONTEND noninteractive
# Python dependencies in some npm modules
RUN apt-get update && \
apt-get install -y -q curl && \
apt-get install -y xvfb x11-xkb-utils xfonts-100dpi \
xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps clang \
libdbus-1-dev libgtk2.0-dev libnotify-dev \
libgconf2-dev libasound2-dev libcap-dev libcups2-dev libxtst-dev \
libxss1 libnss3-dev gcc-multilib g++-multilib && \
apt-get remove -y cmdtest
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update
RUN apt-get install yarn git git-lfs -y && \
apt-get install --fix-missing -y xvfb
# Create directory for the application
WORKDIR /app
.... Load my stuff
# Docker base image is already NODE_ENV=production
RUN npm i -g testcafe && \
yarn
# Build the tests
RUN yarn build-e2e
RUN export NODE_ENV=development && \
export DEBUG=testcafe:*,electron:* && \
xvfb-run -e /dev/stdout -s '-screen 0 1024x768x24' testcafe electron:./app
我也升级到了最新的 testcafe npm 模块
"testcafe": "^1.8.5",
"testcafe-browser-provider-electron": "^0.0.15-alpha.1",
"testcafe-live":"^0.1.4",
"testcafe-react-selectors": "^4.0.0",
.testcaferc.json
{
"src": "./test/e2e/*.js",
"reporter": {
"name": "xunit",
"output": "./reports/report.xml"
},
"screenshots": {
"takeOnFails": true,
"path": "./test/e2e/screenshots"
}
}
.tstcafe-electron-rc.json
{
"mainWindowUrl": "./app/app.html",
"appPath": "./app"
}
没有 headless 一切正常。
我尝试将 --no-sandbox
插入到混音中的几个位置,包括和不包括 xvfb。
此错误表示您正在尝试 运行 root 帐户下的 chrome:headless。尝试将 "appArgs": "--no-sandbox" 选项添加到 .testcafe-electron-rc.json 文件中。
作为替代方法,您可以将非 root 用户添加到容器中并在 运行ning 测试之前切换到它:
https://github.com/DevExpress/testcafe/blob/fc3fe6d527df9b72831133134fb800729f7d3741/docker/Dockerfile#L23
我正在尝试 运行 在 debian docker 容器上以无头模式使用 testcafe-browser-provider-electron 进行 testcafe。
我不断收到
testcafe:browser-provider-electron:spawn:stderr [122:0520/185130.933152:FATAL:atom_main_delegate.cc(211)] Running as root without --no-sandbox is not supported.
See https://crbug.com/63818ERROR Was unable to open the browser "electron:./app" due to error.
我已经在 npx 中以及通过本地安装的 testcafe 中尝试 运行ning。
Docker 文件
FROM node:13.4.0-buster AS builder
ENV DEBIAN_FRONTEND noninteractive
# Python dependencies in some npm modules
RUN apt-get update && \
apt-get install -y -q curl && \
apt-get install -y xvfb x11-xkb-utils xfonts-100dpi \
xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps clang \
libdbus-1-dev libgtk2.0-dev libnotify-dev \
libgconf2-dev libasound2-dev libcap-dev libcups2-dev libxtst-dev \
libxss1 libnss3-dev gcc-multilib g++-multilib && \
apt-get remove -y cmdtest
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update
RUN apt-get install yarn git git-lfs -y && \
apt-get install --fix-missing -y xvfb
# Create directory for the application
WORKDIR /app
.... Load my stuff
# Docker base image is already NODE_ENV=production
RUN npm i -g testcafe && \
yarn
# Build the tests
RUN yarn build-e2e
RUN export NODE_ENV=development && \
export DEBUG=testcafe:*,electron:* && \
xvfb-run -e /dev/stdout -s '-screen 0 1024x768x24' testcafe electron:./app
我也升级到了最新的 testcafe npm 模块
"testcafe": "^1.8.5",
"testcafe-browser-provider-electron": "^0.0.15-alpha.1",
"testcafe-live":"^0.1.4",
"testcafe-react-selectors": "^4.0.0",
.testcaferc.json
{
"src": "./test/e2e/*.js",
"reporter": {
"name": "xunit",
"output": "./reports/report.xml"
},
"screenshots": {
"takeOnFails": true,
"path": "./test/e2e/screenshots"
}
}
.tstcafe-electron-rc.json
{
"mainWindowUrl": "./app/app.html",
"appPath": "./app"
}
没有 headless 一切正常。
我尝试将 --no-sandbox
插入到混音中的几个位置,包括和不包括 xvfb。
此错误表示您正在尝试 运行 root 帐户下的 chrome:headless。尝试将 "appArgs": "--no-sandbox" 选项添加到 .testcafe-electron-rc.json 文件中。
作为替代方法,您可以将非 root 用户添加到容器中并在 运行ning 测试之前切换到它: https://github.com/DevExpress/testcafe/blob/fc3fe6d527df9b72831133134fb800729f7d3741/docker/Dockerfile#L23