I stumbled upon a weird error in CircleCI 2.0 where I couldn't get Google Chrome to work in headless mode when running my VueJS tests in my Laravel app. After a couple of hours of trial and error I finally figured it out, I hope this will save some time for someone out there trying to achieve the same thing.
Karma with Chrome Headless is not working in CI environment.
So I bumped into this error when testing my VueJS tests in my Laravel application in CircleCI 2.0 with the selenium/standalone-chrome:latest docker image.
After googling to no avail I decided that I’d get my hands dirty and started to dig to find a solution. I found that when installing Google Chrome Stable on Ubuntu it creates a bunch of symlinks that all trace back to this file:
Looking into this /opt/google/chrome/google-chrome file, the last lines where:
Looking at the error message my first thought was that the URL was not passed properly as an argument to the google-chrome binary, so I tried running the binary directly instead, which I found was located in /opt/google/chrome/chrome after a global find in the docker container.
I was pleasantly surprised that Google Chrome Stable ran just fine in headless mode when running it directly instead of through the binstub. So I ended up adding a command that tweaks the google-chrome binstub to run the binary directly instead.
This is the final .circleci/config.yml file:
Hope this saves someone out there a couple of hours of debugging.