tanou
tanou

Reputation: 1093

Run ng test (angular-cli karma test) with chrome headless inside docker

We have a docker image based on debian, and we are trying to run our karma unit test. We are using Angular with angular-cli, so we are basically trying to launch our ng test.

We would like to run them in an headless chrome rather than in phantomJS. In order to do that, we installed chrome and we got a dockerFile very similar to this: https://hub.docker.com/r/justinribeiro/chrome-headless/~/dockerfile/.

We configured our karma launcher to add few options, but we are stuck on a problem. It is easily reproductible by launche the command:

google-chrome --headless --no-sandbox --disable-gpu

We got the following error:

libudev: udev_has_devtmpfs: name_to_handle_at on /dev: Operation not permitted

Is somebody has an idea ? Have to admit that we are a bit stuck, here :)

Upvotes: 0

Views: 2421

Answers (1)

tanou
tanou

Reputation: 1093

Okay, I found the problem, wasn't related to docker actually.

I've noticed that karma was launching its server on http://0.0.0.0:9876/, thus I had to add two new flag to my custom karma.conf to launch google-chrome on the correct port:

'--remote-debugging-address=0.0.0.0',
'--remote-debugging-port=9876'

Also, I have to run the container with the --privileged attributes (or --cap-add SYS_ADMIN, but privileged is more complete).

Maybe it'll helps somebody ;)

Upvotes: 3

Related Questions