DevOps Keyvisual doubleSlash CI/CD Pipelines with Playwright

Efficient CI/CD pipelines with Playwright: How to make the most of container technologies

Learn how to cleverly integrate Playwright tests with Docker or Podman into your CI/CD pipeline for a stable and portable test environment.

Do you want to release faster without compromising on quality? Then you need a reliable test strategy.

Playwright - a tool for end-to-end tests - can be combined particularly well with containers.
In this article, I will show you step by step how to Playwright with Docker or Podman efficiently into your CI/CD pipeline.

Why containers are worthwhile for automated tests

Container technologies such as Docker and Podman allow you to run applications in isolated environments. This keeps your test environments consistent - no matter where you run them. With the Playwright container image, your tests run smoothly locally and in the pipeline - without setup chaos.

How to cleverly integrate external test projects into the pipeline

1. create fat JAR:

  • Configure your separate test project so that it creates a fat JAR. This can be done with build tools such as Maven or Gradle.

2. load Fat-JAR into the pipeline:

  • Use wgetto load the fat JAR into your CI/CD pipeline and save it in an accessible directory, e.g. in the lib-folder.
  • Example command:
wget -P ${WORKSPACE}/lib http://example.com/path/to/your-test-project-fat.jar

3. run tests in the container:

  • Use Docker or Podman to run the tests in the container.
  • With Docker:
docker run --rm -t -v ${WORKSPACE}:${WORKSPACE} -w ${WORKSPACE}
mcr.microsoft.com/playwright/java:latest java -cp "${WORKSPACE}/lib/*"
org.junit.platform.console.ConsoleLauncher -c YourTestClass
  • With Podman:
podman run --rm -t -v ${WORKSPACE}:${WORKSPACE} -w ${WORKSPACE}
mcr.microsoft.com/playwright/java:latest java -cp "${WORKSPACE}/lib/*"
org.junit.platform.console.ConsoleLauncher -c YourTestClass

These steps ensure that the lib-folder containing the downloaded fat JAR is mounted in the container and the class path is set so that it can access the fat JAR.

How to bring Playwright cleanly into your CI/CD pipeline

First check whether your CI/CD environment supports Docker or Podman. Then integrate the steps from the previous section directly into your build or test job. This way, your tests run automatically, portably and in isolation.

Conclusion: What you take away from this setup

The combination of Playwright, containers and Fat JAR strategy offers you a stable test infrastructure that can be easily integrated into CI/CD processes.
This allows you to test reliably, portably and independently of local setups.

Try it out - and see how much more scalable your tests become.

I hope this approach helps you to successfully integrate your tests into the CI/CD pipeline!

Fabian Kock

About ME

All contributions from Fabian Kock

Learn more

Further information on our website and in our newsletter

Arrow up