Karma unit test failure when building Bahmni Apps (ERROR [launcher]: Cannot start Firefox)

Hey Bahmni team,

I figured I’d check in with you all in the hope that you have an obvious fix for this. I was trying to build bahmniapps via the grunt command, and it is failing during the karma test run due to the inability to load Firefox.

I can run this fine on my host machine, but when I try it on a Vagrant box running Ubuntu server (or on one of our cloud-based servers) it fails. My assumption is that this is due to the fact that there is no window manager for Firefox to run in, but I wanted to check in with you all before I spent too much time investigation. Is there something you have had to do on your CI servers in order to get this to work?

See below for what I am seeing:

vagrant@vagrant-ubuntu-trusty-64:~/openmrs-module-bahmniapps/ui$ grunt test
Running "karma:unit" (karma) task
WARN [watcher]: Pattern "/home/vagrant/openmrs-module-bahmniapps/ui/app/components/offline/offline.min.js" does not match any file.
INFO [karma]: Karma v0.12.37 server started at http://localhost:9876/
INFO [launcher]: Starting browser Firefox
ERROR [launcher]: Cannot start Firefox
INFO [launcher]: Trying to start Firefox again (1/2).
ERROR [launcher]: Cannot start Firefox
INFO [launcher]: Trying to start Firefox again (2/2).
ERROR [launcher]: Cannot start Firefox
ERROR [launcher]: Firefox failed 2 times (cannot start). Giving up.
Warning: Task "karma:unit" failed. Use --force to continue.

Aborted due to warnings.

Thanks! Mike

See browsers configuration in karma.conf.js. You can change the browser to PhantomJS if you don’t want to use a real browser. (See configurations

By the way, we run tests on Firefox on centos using xvfb (a virtual frame buffer). You will need to install firefox and xvfb to do this. Some configuration we use available here.

Thanks @vinay - using that bundled packaging script works great - thanks for pointing that out. I wanted to avoid modifying karma.conf.js to use another browser since that would require modifying the source of bahmniapps and getting out of sync with the master repository.

Thanks again, Mike