Re-run Only Failed Tests

How to setup failed tests re-run on GitLab

When a workflow fails in GitLab CI/CD you have the option to re-run the failed jobs. However, an additional setup is required for properly configuring Playwright for rerunning only the failed tests. See Re-run Only Failed Testsarrow-up-right guide for details.

Rerunning only the failed jobs on GitLab CI/CD

Playwright Sharding

If you're using Playwright Shardingarrow-up-right for running your tests in parallel, use currents cachearrow-up-right command to store the last run results and simplify re-run workflows.

Example workflows are available in our GitLab repositories:

chevron-rightInstall the @currents/cmd packagehashtag
chevron-rightAdd an after_script to upload the cachehashtag

Add an after_script to the end of your job that uploads run information to the cache

See the configuration for details on the flags.

chevron-rightAdd a download cache step to you scripthashtag

Update your job script to download the cache prior to running tests

See the configuration for details on the flags.

chevron-rightA full examplehashtag

Currents Orchestration

In case you're using Orchestration Setup for running your Playwright tests in parallel, use currents api command to fetch the results of the last run from the API.

An example workflow is available in our GitLab demo repository

chevron-rightInstall the @currents/cmd packagehashtag
chevron-rightSet CURRENTS_API_KEY environment variablehashtag

Obtain an API key (see Authentication) and Record Key from Currents Dashboard and set GitLab CI/CD variablearrow-up-right accordingly

chevron-rightAdd an after_script to upload the cachehashtag

Add an after_script to the end of your job that uploads GitLab retry information to the cache

See currents cache documentation for all the available options

chevron-rightAdd an api get-run step to you scripthashtag

Update your job script to download the cache prior to running tests, and then also grab the previous run.

See currents api documentation to explore all the available options

chevron-rightA full examplehashtag

Last updated

Was this helpful?