facebook-atom / jest-electron-runner

custom test runner for Jest that allows tests to be run in Electron environment
MIT License
189 stars 33 forks source link

Fails to run on Gitlab CI #70

Open debjitbis08 opened 4 years ago

debjitbis08 commented 4 years ago

Configurations

jest.config.js

module.exports = {
    setupFiles: ["./test-setup.js"],
    runner: "@jest-runner/electron",
    testEnvironment: "@jest-runner/electron/environment",
    collectCoverageFrom: ["**/*.js", "!**/node_modules/**"],
    coverageReporters: ["text", "lcov"],
    testResultsProcessor: "jest-sonar-reporter"
};

.gitlab-ci.yml

validation:
    stage: validation
    before_script:
        - apt-get update && apt-get install -y xvfb libxtst6 libnss3 libatk-bridge2.0-0 libgtk-3-0 libxss1 libasound2
    script:
        - npm ci --cache .npm --prefer-offline
        - echo "Running tests now"
        - export ELECTRON_DISABLE_SANDBOX=1
        - xvfb-run npm test

package.json

  "scripts": {
    "test": "npm run lint && jest --config ./src/lib-code/jest.config.js",
    "lint": "eslint src/lib-code"
  },
  "devDependencies": {
    "electron": "^9.2.1",
    "jest": "^26.4.0"
  },

Docker image used: node:latest

Output

Fontconfig warning: "/etc/fonts/fonts.conf", line 100: unknown element "blank"
[1071:0819/190428.116634:FATAL:gpu_data_manager_impl_private.cc(439)] GPU process isn't usable. Goodbye.

To solve this I probably need to pass the --disable-gpu flag to electron, but I can't find a way to do it currently. Also, I have read elsewhere that running electron on Gitlab requires the --disable-dev-shm-usage flag but I don't think there is way to pass that parameter currently.

catdad commented 4 years ago

There are in fact various flags that need to be passed into electron in various different scenarios (CI, docker, wsl, etc.). The way that other systems, like cypress for example, have handled this is by including and extra variable like ELECTRON_EXTRA_LAUNCH_ARGS where we can define any number of arguments. There should be something similar that allows adding any arbitrary flags.