在无头容器中发出带有电子的运行测试网

问题描述 投票:2回答:1

我正在尝试在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运行。

Dockerfile

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"
}

没有头也没事。

我已经尝试过在[x0fb]和[xvfb]的不同位置插入--no-sandbox

我正在尝试在debian docker容器上以无头模式运行带有testcafe-browser-provider-electron的testcafe。我不断收到testcafe:browser-provider-electron:spawn:stderr [122:0520 / ...

node.js docker testing electron testcafe
1个回答
1
投票

此错误表示您正在尝试在根帐户下运行chrome:headless。尝试将“ appArgs”:“ --no-sandbox”选项添加到.testcafe-electron-rc.json文件中。

© www.soinside.com 2019 - 2024. All rights reserved.