¿Cómo usar 'resizeWindow' con Docker y electron en Testcafe?

Aug 21 2020

Tengo un problema usando resizeWindowdesde Testcafe dentro de un contenedor ventana acoplable al probar una aplicación de electrones con gitlab.

Nota : En la configuración local (Linux), todas las pruebas funcionan como se esperaba, pero dentro del contenedor de la ventana acoplable resizeWindowno parece funcionar. Otras pruebas dentro del contenedor también funcionan.

¿Quizás me falta alguna configuración para xvfbo debería usar fluxbox?

¿Alguna sugerencia de cómo solucionar esto?


Error de prueba con Docker:

$ yarn test-e2e-ci yarn run v1.22.4 $ node -r @babel/register ./internals/scripts/CheckBuildsExist.js && cross-env NODE_ENV=test testcafe electron:./ci ./test/e2e/DockerTest.e2e.ts --screenshots takeOnFails=true
 Running tests in:
 - Electron 9.0.4 / Linux 0.0
 Docker execution
 ✖ `ResizeWindow` works as expected 
   1) AssertionError: expected 1024 to deeply equal 100
      Browser: Electron 9.0.4 / Linux 0.0
          8 |
          9 |test('`ResizeWindow` works as expected ', async t => {
         10 |  await t.resizeWindow(100, 100);
         11 |  const innerWidth = await t.eval(() => window.innerWidth);
         12 |  const innerHeight = await t.eval(() => window.innerHeight);
       > 13 |  await t.expect(innerWidth).eql(100);
         14 |  await t.expect(innerHeight).eql(100);
         15 |});
         16 |
         at <anonymous>
      (/builds/myFancyProject/test/e2e/DockerTest.e2e.ts:13:30)
         at fulfilled
      (/builds/myFancyProject/test/e2e/DockerTest.e2e.ts:5:58)
 1/1 failed (8s)

Advertencias:

 Warnings (3):
 --
  Was unable to resize the window due to an error.
  The
  /builds/myFancyProject/node_modules/testcafe-browser-tools/bin/linux/glibc-64/resize
  process failed with the null exit code.
 --

Configuración de prueba utilizada:

Prueba ResizeWindow Testcafe

test('`ResizeWindow` works as expected ', async t => {
  await t.resizeWindow(100, 100);
  const innerWidth = await t.eval(() => window.innerWidth);
  const innerHeight = await t.eval(() => window.innerHeight);
  await t.expect(innerWidth).eql(100);
  await t.expect(innerHeight).eql(100);
});

Iniciar dentro de gitlab yml

- xvfb-run --server-num=99 --server-args='-ac -screen 0 1024x768x16' yarn test-e2e-ci

package.json

"test-e2e-ci": "node -r @babel/register ./internals/scripts/CheckBuildsExist.js && cross-env NODE_ENV=test testcafe electron:./ci ./test/e2e/ --screenshots takeOnFails=true",

./ci/.testcafe-electron-rc

{
  "mainWindowUrl": "../app/app.html",
  "appPath": "../app",
  "appArgs": "--no-sandbox"
}

Imágenes de Docker probadas:

circleci/node:latest-browsers

FROM node:lts-stretch

RUN apt-get update \
    && apt-get install -y xvfb \
    libnotify4 \
    libgconf2-4 \
    libnss3 \
    libxtst-dev \
    libc6 \
    libstdc++6 \
    libgcc1 \
    libgtk-3-0 \
    libasound2 \
    libxrender1 \
    libxss1

Respuestas

2 mlosev Aug 24 2020 at 10:35

Necesita instalar y configurar correctamente la fluxboxherramienta. Vea un ejemplo en los archivos relacionados de la ventana acoplable TestCafe:

  • https://github.com/DevExpress/testcafe/blob/master/docker/Dockerfile
  • https://github.com/DevExpress/testcafe/blob/master/docker/testcafe-docker.sh