hustcc / jest-electron

❯ ⚛️The easiest way to run and debug test cases in electron with jest.
https://github.com/hustcc/jest-electron
MIT License
154 stars 24 forks source link

Problem running inside docker container #41

Open fredcido opened 3 years ago

fredcido commented 3 years ago

Hello all, I am trying to run the tests inside a docker container, following the steps, using the following configuration:

FROM node:14

RUN apt-get update -y && apt-get install -y xvfb
ENV DISPLAY=':99'
RUN Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
RUN npm test

However, the tests hang, with no error message at all, I can't even get a clue on what's going on:

npm test

> upc@1.0.0 test /app
> jest "--selectProjects" "e2e" "--verbose"

Running one project: e2e

Test Suites: 0 of 5 total
Tests:       0 total
Snapshots:   0 total
Time:        422 s

Any hint on what's going on? I can't see any log messages

dietergeerts commented 3 years ago

With the same setup as above, i do get the error:

events.js:292
 throw er; // Unhandled 'error' event
 ^

Error: spawn /app/common/temp/node_modules/.pnpm/electron@6.1.12/node_modules/electron/dist/electron ENOENT
 at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
 at onErrorNT (internal/child_process.js:465:16)
 at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
 at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
 at onErrorNT (internal/child_process.js:465:16)
 at processTicksAndRejections (internal/process/task_queues.js:80:21) {
 errno: -2,
 code: 'ENOENT',
 syscall: 'spawn /app/common/temp/node_modules/.pnpm/electron@6.1.12/node_modules/electron/dist/electron',
 path: '/app/common/temp/node_modules/.pnpm/electron@6.1.12/node_modules/electron/dist/electron',
 spawnargs: [
 '/app/common/temp/node_modules/.pnpm/jest-electron@0.1.11_jest@26.6.3/node_modules/jest-electron/lib/electron/main/index'
 ]
}
hustcc commented 2 years ago

maybe new version 0.1.12 solved it.

sta-ger commented 1 year ago

jest-electron does not throw error if some library is missing. I managed to solve this by installing the system libraries needed to run Electron headless and running "npm test" with "xvfb-run":

FROM node:14

COPY . /usr/src/app
WORKDIR /usr/src/app

ENV JEST_ELECTRON_STARTUP_ARGS='--no-sandbox'

RUN apt-get update && apt-get install -y  \
    libnss3  \
    libatk1.0-0  \
    libatk-bridge2.0-0  \
    libgbm1  \
    libgtk-3-0  \
    libasound2  \
    xvfb

RUN npm ci

CMD xvfb-run npm test