I am trying to run testcafe with the testcafe-browser-provider-electron in headless mode on a debian docker container.
I keep getting
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.
I have tried running in npx as well as via locally installed 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
I upgraded to the latest testcafe npm modules as well
"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"
}
It all works fine without headless.
I have tried to insert --no-sandbox
into the mix in several spots, with and without xvfb as well.
This error means that you are trying to run the chrome:headless under the root account. Try to add the "appArgs": "--no-sandbox" option into the .testcafe-electron-rc.json file.
As an alternate way, you can add a non-root user into the container and switch to it before running tests: https://github.com/DevExpress/testcafe/blob/fc3fe6d527df9b72831133134fb800729f7d3741/docker/Dockerfile#L23