How to Run Your Tests Headless with Xvfb
Intro
If you want to run your tests headless on a Continuous Integration (CI) server you'll quickly realize that you can't with an out-of-the-box setup since there is no display output for the browser to launch in.
A Solution
In order to run your tests using a browser that's loaded on your CI Server you will need to configure your tests to launch the browser virtually (e.g., using something like Xvfb).
NOTE: If you only need to run Chrome on a machine without a display, headless Chrome is simpler: it needs no extra tools. Xvfb is useful when the browser needs a real window, e.g., to run it headed on a Linux CI server, or to use a feature that headless mode does not have.
An Xvfb primer
Xvfb (short for X virtual framebuffer) is an in-memory display server forUNIX-like operating system (e.g., Linux). It enables you to run graphical applications without a display (e.g., browser tests on a CI server) while also having the ability to take screenshots.
Let's take a look at an example.
Special Thanks

Authors

