A so-called headless browser is a full featured browser that can be started on the command line, and behaves just like any other browser but simply does not come with a browser window.
Most importantly, it can be used programmatically: You can write code that asks this browser to navigate to a certain page, click on a link, submit a form, and so on.
Headless browsers can be used to test the user’s experience in a more complete way.
Rack::Test based tests (and friends, there are other libraries that do similar things) simply instantiate the application, run a fake request against it, and then inspect the response. This works great for simple applications like our Sinatra app.
Headless browsers allow us to write full stack tests. These tests tend to be a little slower, and potentially more brittle. But they’re a great tool to have on your belt as a developer.
There are several headless browsers out there, and their quality isn’t always the greatest.
So, let’s have a look at Phantom.js next.