Image by petcoffr.
Phantomjs is a great tool for end-to-end tests of your application. It provides a headless browser based on webkit that allows your tests to navigate through the web application.
At Codeship we use its capybara integration, but Phantomjs can be used for lots of purposes. Throughout the lifetime of our codebase we have tried various Capybara drivers to find the one that suits our test environment and workflow.
Selenium broke frequently when new Firefox versions were released which were incompatible with older versions of the selenium-webdriver gem. Another issue was that Selenium had problems with links covered by modal panels. One of our customers experienced the same behavior in capybara-webkit. PhantomJS correctly failed and provided the right error messages.
Getting started with PhantomJS
Following is a minimal setup gist to get you started. The Poltergeist gem integrates PhantomJS with Capybara and provides a lot of great extensions. Take a look at their customization options to get a better understanding of what you can do.
Here is the Capybara config with the parallel_tests gem setup we use for Codeship:
Give PhantomJS a try for your test environment! It is a stable, easy to use and a powerful friend.
Want to build tools for other developers and join a well funded startup? Join us and bring Continuous Deployment to every software team. We are hiring!