Playwright - Jenkins
Running Playwright tests in parallel with Jenkins and Currents Dashboard
Last updated
Running Playwright tests in parallel with Jenkins and Currents Dashboard
Last updated
Here's an example of Jenkins pipeline that is running Playwright tests in parallel on 2 workers.
The pipeline will be running 2 workers, based on mcr.microsoft.com/playwright:v1.34.0-jammy
Docker image. Those workers will run all the tests in parallel.
The steps are:
Use mcr.microsoft.com/playwright:v1.34.0-jammy
as the base image
Install the necessary dependencies: playwright
and @currents/playwright
Populate the environment variable CURRENTS_RECORD_KEY
using . Learn more about Record Key
Populate the environment variable CURRENTS_PROJECT_ID
using .
Run Playwright tests on 2 workers, using CI Build ID for "connecting" the workers to the same parallel run. See CI Build ID.
Here's the full Jenkins pipeline configuration file:
Here you will be able to find the following Jenkinsfile that accepts two parameters:
A CI Build ID from a previous run that you can use to apply the --last-failed
flag. If this parameter is set, then the pipeline will automatically apply this tag and only run the failed tests from that run if found.
A checkbox for knowing if you want to run an orchestrated run. If so, the pipeline will use pwc-p
command instead of pwc
.
In order to use the --last-failed
flag, in addition to the project ID and record key, a Currents API key is needed (You can find it in the API Keys section in your dashboard).
Also, within the Jenkinsfile you can set different values as env variables for the total amount of shards TOTAL_SHARDS
or the number of parallel jobs for orchestration PARALLEL_JOBS.
We have made available a of how to setup last failed functionality using shards and orchestration in different machines.
This example uses the API Key and the package to query for the run corresponding to the CI Build ID and generates the .last-run.json
file with that information.