3

First time asking a question on SO. Please be kind. I will graciously accept question feedback.

I have a Jenkins instance running on an openSUSE Linux machine that I do not have root access to. I have configured Jenkins with a custom tool installation that pulls in Firefox 56.0.1 from https://ftp.mozilla.org/pub/firefox/releases/56.0.1/linux-x86_64/en-US/firefox-56.0.1.tar.bz2

I have an Angular app that's built on the Angular CLI. Here is the relevant section of my karma.conf.js:

browsers: ['FirefoxHeadless'],
singleRun: true,
customLaunchers: {
  'FirefoxHeadless': {
    base: 'Firefox',
    flags: [
      '-headless',
    ],
  }

My Jenkins has a job that pulls the Angular app and runs ng test using Firefox 56.0.1 with the -headless flag. However, it fails with the following feedback:

ERROR [launcher]: [39mCannot start Firefox

(process:3050): GLib-CRITICAL **: g_slice_set_config: assertion 
'sys_page_size == 0' failed
Error: no display specified

Research into this error points to xvfb needing to be run for Selenium and a DISPLAY environment variable being set so that Firefox can connect to that display. Since this is supposed to be headless, I don't believe that xvfb should be required since running headless should not require a graphical display (I do not want to go through the work of trying to install xvfb on a machine I do not have root access to). Adding the DISPLAY environment variable only changes the error to cannot open display: :10.

How do I get my jenkins instance to run karma tests in a headless version of Firefox?

binskits
  • 248
  • 1
  • 3
  • 10
  • 1
    You may just need to install some additional libraries that firefox is linking against [See bug on Bugzilla](https://bugzilla.mozilla.org/show_bug.cgi?id=1372998) – Todd Oct 23 '17 at 18:16

1 Answers1

4

I came across your answer when searching for why Firefox as a browser did work on Windows but not on my non-GUI linux buildserver. Seeing that you named your custom browser launch config FirefoxHeadless made me remember I have heard of such a preset before: The Firefox launcher for Karma supports a handful of ready-to-use launch configs which will launch Firefox with the right launch options:

Firefox
FirefoxHeadless
FirefoxDeveloper
FirefoxDeveloperHeadless
FirefoxAurora
FirefoxAuroraHeadless
FirefoxNightly
FirefoxNightlyHeadless

The package is available via NPM. Using this might save you and others the hassle of additional launch configs.

gekkedev
  • 562
  • 4
  • 18