It seems like something has changed in Firefox 61 which has resulted in karma-firefox-launcher to be unable to properly start firefox. The following configuration works fine for firefox 60.
karma.conf
....
browsers: ['FirefoxHeadless'],
customLaunchers: {
FirefoxHeadless: {
base: 'Firefox',
flags: [
'-headless'
],
},
},
....
> ng test --browsers FirefoxHeadless
10% building modules 1/1 modules 0 active(node:70) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
19 07 2018 16:28:03.691:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
19 07 2018 16:28:03.693:INFO [launcher]: Launching browser FirefoxHeadless with unlimited concurrency
19 07 2018 16:28:03.698:INFO [launcher]: Starting browser Firefox
20% building modules 91/105 modules 14 active …s/form-plugin/fesm5/ngxs-form-plugin.js19 07 2018 16:28:05.106:ERROR [launcher]: Cannot start Firefox *** You are running in headless mode.
19 07 2018 16:28:05.107:ERROR [launcher]: Firefox stdout:
19 07 2018 16:28:05.107:ERROR [launcher]: Firefox stderr: *** You are running in headless mode.
24% building modules 120/147 modules 27 active …modules/core-js/modules/_string-trim.js19 07 2018 16:28:05.483:INFO [launcher]: Trying to start Firefox again (1/2).
54% building modules 370/398 modules 28 active …nal/observable/ConnectableObservable.js19 07 2018 16:28:06.468:ERROR [launcher]: Cannot start Firefox
*** You are running in headless mode.
19 07 2018 16:28:06.468:ERROR [launcher]: Firefox stdout:
19 07 2018 16:28:06.469:ERROR [launcher]: Firefox stderr: *** You are running in headless mode.
59% building modules 415/435 modules 20 active …modules/core-js/modules/es6.array.of.js19 07 2018 16:28:06.570:INFO [launcher]: Trying to start Firefox again (2/2).
95% emitting CopyPlugin19 07 2018 16:28:12.559:ERROR [launcher]: Cannot start Firefox
*** You are running in headless mode.
19 07 2018 16:28:12.559:ERROR [launcher]: Firefox stdout:
19 07 2018 16:28:12.559:ERROR [launcher]: Firefox stderr: *** You are running in headless mode.
19 07 2018 16:28:12.681:ERROR [launcher]: Firefox failed 2 times (cannot start). Giving up.
It seems like something has changed in Firefox 61 which has resulted in
karma-firefox-launcherto be unable to properly start firefox. The following configuration works fine for firefox 60.