I want to start Firefox using Xvfb to run Karma in a headless server.
Karma needs a launcher plugin to start and stop browsers automatically. I've found a karma-xvfb-chrome-launcher, but no one for Firefox.
After installing Xvfb (Ubuntu), I know I can start Firefox using the following command:
$ xvfb-run firefox <app-under-test-url>
What I don't know is how to make Karma start Firefox this way.
Is there a way to provide a custom start/stop browser script to Karma work with?
Is possible to do it via Karma.conf.js?
How can I do that?
Thanks!
You can use xvfb-run to start Karma, and any browser it launches will run in a new Xvfb instance.
In a Makefile of mine I have this command which is run when I want to run my Karma-based tests:
xvfb-run karma start --single-run
xvfb-run operates by starting an Xvfb instance, grabbing its display number and setting the DISPLAY environment variable, then it runs the command you passed as argument. This means that everything that is executing through xvfb-run (including any new processes started from the initial one) is using the DISPLAY value that xvfb-run has set and consequently will appear on the Xvfb instance that xvfb-run started.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With