GitLab

How GitLab switched to Headless Chrome for testing

Dec 19, 2017Mike Greiling
How GitLab switched to Headless Chrome for testing
SummaryAI, from the source post

This post details the technical migration from PhantomJS to headless Chrome for GitLab's testing infrastructure. It outlines the reasons for the switch, including PhantomJS's outdated components and lack of modern browser features. For frontend tests using Karma, the change involved updating the `karma-chrome-launcher` plugin. For backend feature tests using RSpec and Capybara, the migration required switching from the Poltergeist driver to Selenium and ChromeDriver. Key challenges and solutions are presented, including adapting to Selenium's handling of JavaScript modals (`accept_alert`, `accept_confirm`), differences in element visibility checks (`visible: :any`), and the absence of Poltergeist's `.trigger('click')` method, necessitating test refactoring to use standard `.click` actions or alternative event simulation. The post also provides configuration examples for Capybara and discusses the benefits of running tests in a real browser environment.