Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Karma tests from docker container?

I've recently moved my node.js app into a docker image and I'd like to run my tests inside the image. My mocha/node tests work fine but the Karma tests involve starting Chrome to run the tests and Chrome isn't installed in the container.

How do I go about addressing this?

  • Install Chrome in the Container? Seems less than ideal as I don't want to ship Chrome to my production servers inside the container.
  • Somehow allow it to connect to Chrome on the host?
  • Create a new image that inherits from my app image and adds Chrome and other things?

Googling 'docker & karma' reveals docker images out there but I can't find instructions on how to think about the problem and the best approach.

like image 880
MichaelJones Avatar asked Dec 15 '15 10:12

MichaelJones


People also ask

Is Docker used for testing?

Docker Hub can automatically test changes to your source code repositories using containers. You can enable Autotest on any Docker Hub repository to run tests on each pull request to the source code repository to create a continuous integration testing service.


1 Answers

I've found this docker image to be an excellent starting point for running karma tests quickly inside a docker container on Concourse CI:

https://hub.docker.com/r/markadams/chromium-xvfb-js/

It contains node 6.x (latest) + npm and a headless chromium instance using X virtual framebuffer. Working great for me!

like image 65
Johannes Rudolph Avatar answered Sep 25 '22 11:09

Johannes Rudolph