Dockerize your TestCafe tests and integrate with Jenkins

Wait, we have a checklist

  • Of course, you have to install Docker. Installation is dead easy. I assume you have a basic understanding of Docker and Dockerfile.
  • Get the Jenkins war file. Just keep it in a folder for now.
  • In case you want to try the things out in a sample repository, clone this Testcafe-Starter pack from Github. This pack has different lifecycle hooks like building, linting, and reporting integrated. The reporting partner is Allure, you need to install JDK inside the docker to create the desired reports. So, this pack is ideal to understand how to frame the Docker image with all dependencies.

But, what does Docker images really do?

Let’s create our Dockerfile

Create and test your Docker Image

docker build -t testcafe -f docker/Dockerfile .
docker images -a
docker run -u root -v ${PWD}:/tests -it testcafe/testcafe chromium /tests/**/*.spec.ts
docker stop $(docker ps -qa --filter ancestor=testcafe)

Create your Jenkins file

Boot up Jenkins and Configure Test job

java -jar jenkins.war --httpPort=9090

Execute your first TestCafe job

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhinaba Ghosh

Abhinaba Ghosh

Tech Lead Manager @Postman 🚀 | Space Movie Lover 🪐 | Coder 👨‍💻 | Traveller ⛰️