Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use karma-electron with Xvfb #17

Closed
track0x1 opened this issue Dec 2, 2016 · 5 comments
Closed

Unable to use karma-electron with Xvfb #17

track0x1 opened this issue Dec 2, 2016 · 5 comments
Labels

Comments

@track0x1
Copy link

track0x1 commented Dec 2, 2016

Trying to run my unit tests headless on a linux box with electron but this doesn't let electron launch in Xvfb. :(

@twolfson
Copy link
Owner

twolfson commented Dec 2, 2016

Please make sure you are setting a DISPLAY environment variable that will be shared by Xvfb and karma. Here's the typical Travis CI setup:

https://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-xvfb-to-Run-Tests-That-Require-a-GUI

and here it is working in this very repo with Travis CI (uses default npm test via Travis CI):

https://github.com/twolfson/karma-electron/blob/5.1.1/.travis.yml#L16-L22

There's also a cleaner variant suggested by Electron's docs:

https://github.com/electron/electron/blob/v1.4.10/docs/tutorial/testing-on-headless-ci.md

@track0x1
Copy link
Author

track0x1 commented Dec 5, 2016

I have DISPLAY defined and I can tell the display is configured properly because I can run firefox without an error. but this is what I see when I try karma:

$ ps -a
  PID TTY          TIME CMD
 2511 tty1     00:00:00 bash
13232 pts/1    00:00:00 Xvfb
13336 pts/1    00:00:00 ps

$ echo $DISPLAY
:99.0

$ ./node_modules/.bin/karma start ./karma.config.js --single-run
05 12 2016 11:27:27.981:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
05 12 2016 11:27:27.983:INFO [launcher]: Launching browser Electron with unlimited concurrency
05 12 2016 11:27:28.085:INFO [launcher]: Starting browser Electron
05 12 2016 11:27:28.201:ERROR [launcher]: Cannot start Electron
	
05 12 2016 11:27:28.849:INFO [launcher]: Trying to start Electron again (1/2).
05 12 2016 11:27:28.889:ERROR [launcher]: Cannot start Electron
	
05 12 2016 11:27:28.910:INFO [launcher]: Trying to start Electron again (2/2).
05 12 2016 11:27:28.947:ERROR [launcher]: Cannot start Electron
	
05 12 2016 11:27:28.952:ERROR [launcher]: Electron failed 2 times (cannot start). Giving up.

@twolfson
Copy link
Owner

twolfson commented Dec 5, 2016 via email

@track0x1
Copy link
Author

track0x1 commented Dec 6, 2016

Sweet! Found out that I needed to install libXss. Did that and it works! Thanks :)

@sanbor
Copy link

sanbor commented Mar 6, 2017

Here is the list of dependencies in Debian (from segment-boneyard/nightmare#224 (comment)):

xvfb
libgtk2.0-0
libgconf-2-4
libasound2
libxtst6
libxss1
libnss3

Here is a Dockerfile with the dependencies for CentOS. I had to install the following dependencies in CentOS 7:

yum install -y \
  libX11-devel.x86_64 \
  pixman-devel.x86_64 \
  libdrm-devel.x86_64 \
  mesa-libGL-devel.x86_64 \
  openssl-devel.x86_64 \
  xorg-x11-xtrans-devel.noarch \
  libXfont-devel.x86_64 \
  libxkbfile-devel.x86_64 \
  libpciaccess-devel.x86_64 \
  xorg-x11-utils \
  libXtst-devel.x86_64 \
  libjpeg-turbo-devel.x86_64 \
  gtk2-2.24.28-8.el7.x86_64 \
  libXScrnSaver-1.2.2-6.1.el7.x86_64 \
  GConf2-3.2.6-8.el7.x86_64 \
  alsa-lib-1.1.1-1.el7.x86_64 \
  'gnu-free-sans-fonts'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants