Orchestration Setup
Setup instructions for Playwright Orchestration
Migrating from v1? See Migration Guide.
Orchestration helps decrease the duration of Playwright tests in CI pipelines. Read our detailed guide on Playwright Parallelization that compares native sharding with orchestration.
How does it work
At a high level:
creates a list of tests for orchestration using
pwc-p discoverestablishes an orchestration session with Currents servers
assigns work to available CI machines using historical execution and timing data
records results to Currents for troubleshooting and analysis
@currents/playwright includes a CLI command pwc-p that implements Playwright Orchestration.
pwc-p discover— runs Playwright in discovery mode and writes the list of tests to be orchestrated to a file.pwc-p run— initiates the orchestrated execution based on the previous step.
Setup
Install @currents/playwright
npm i @currents/playwright@latestRun
pwc-p discoverto create a discovery file with tests selected for orchestration, you can apply the same filters and CLI arguments as forplaywrightcommand.Run
pwc-p runwith--pwc-discovery-fileto execute the orchestration. Runpwc-p run --helpto see the available flags or refer to @currents/playwright.
A successfully created orchestration prints an output similar to this.
Currents automatically balances tests between all available CI machines, which makes --shard redundant — it should be removed.
Read more about CI Build ID and Reporting Strategy.
When to use discover
discoverpwc-p discover is required when you want to explicitly select tests for orchestration — for example:
Filtering tests by tag:
--grep / -g @smokeFiltering tests by last run outcome:
--last-failed(see Re-running Only Failed Tests)Filtering tests by Playwright project:
--project chromiumExplicit spec file location:
playwright test <spec-file-path>
Apply the desired arguments and parameters as if you are running playwright command, for example:
Omitting discovery stage selects all tests for orchestration.
Run the full suite (no filters)
pwc-p run ...
Filter tests with Playwright flags
first pwc-p discover ... then pwc-p run ...
Discovery output
Creates a discovery file at a destination, then use the file as an input for pwc-p run command
Additional methods for providing discovery file:
CURRENTS_DISCOVERY_FILEenvironment variableorchestration.discoveryFileincurrents.config.ts
CURRENTS_DISCOVERY_FILE or orchestration.discoveryFile are the recommended options for CI environments, as this setup applies to both discover and run commands.
Examples
Filter with grep:
Filter with last-failed:
Add tags on the recorded run (no discovery step):
Run pwc-p discover --help or pwc-p run --help to see the list of supported flags.
Orchestration in CI
Provider-specific orchestration examples are being updated for discover and run. Use these pages as starting points:
Orchestration and Reporters
Additional Reporters
pwc-p run automatically injects Currents reporter @currents/playwright into Playwright, replacing all other reporters configured in playwright.config.ts. To add additional reporters use one of the two options.
Add reporters as a CLI parameter.
Manual Configuration
Create currents.config.ts with the following contents:
Update
playwright.config.ts
Optional: Update the
pwc-p runCLI command
pwc-p run reads all the configuration from currents.config.ts — no need to use CLI params.
Merging Fragmented Reports
Orchestration dynamically pulls test files from a central server, and each pull starts a fresh Playwright process. This can impact reporters that write output files—since a new process runs for each pull, you may need to handle file overwrites and merge results correctly.
The solution is to use the blob reporter to gather all the fragmented results and merge them.
You can generate other reports by passing the blob results to the merge-reports command.
Check an example of Github Actions setup here.
Orchestration and Multiple Workers
Orchestration adjusts to make the best use of the available workers.
When multiple workers are enabled, the orchestrator creates a "batch" of multiple test files to ensure the most optimal utilization of all the available workers. The batch runs as single playwright command.
As of May 2025, the Playwright Test Runner does not respect the execution order of test files. This means that even if Currents suggests an optimal execution order, Playwright may run files in a different sequence when multiple workers are used. It only affects cases when multiple workers are involved and has a minor impact.
Having multiple workers behaves differently in Playwright's Fully Parallel Mode. If you are using Fully Parallel Mode, and most of your test files contain more than one test, you will want to keep your Batch Size at 1 and your Playwright workers at a larger number.
Batch size configuration
The batch size can be configured via env variable or cli option.
Starting at @currents/playwright version 1.14.0 and @playwright/test version starting at 1.52.0 the option can be set per project.
This means that the batch size can be handled globally, that also supports automatic detection of global workers, but also the project level workers and batch size is taken into account for defining the batch size.
Batch size for each project is determined by evaluating options in the following order of priority:
Global batch size
A global batch size defined via environment variable or CLI option will override any batch size or worker settings defined at the project level.
Starting with version 1.13.0, the reporter can automatically detect and use the global worker count as the batch size, if global workers are defined.
Project batch size
currentsBatchSize defined at project level
This configuration is available in@currents/playwright version starting at 1.14.0 and @playwright/test version starting at 1.52.0
Project workers
workers defined at project level
This configuration is available in@currents/playwright version starting at 1.14.0 and @playwright/test version starting at 1.52.0
Global workers
Default
If none of the above is defined, batch size is 1
Project level workers
This feature allows you to set the number of workers at project level, enabling each project to specify its own batch size based on the workers.
This is how the workers can be defined:
Currents will use the batch size auto option by default. This means the reporter will read each project workers setting and use it as batch size.
If no workers are defined for a project, Currents will use the global workers value as batch size.
Project level batch size
The Playwright project configuration can be extended with currentsBatchSize which explicitly sets the batch size per project. Import CurrentsFixtures for typescript suport.
In this example, the chromium project has 2 workers defined. However, since the currentsBatchSize property is set, Currents will use the specified currentsBatchSize instead of the workers value.
For the firefox project, the currentsBatchSize is set to auto, so Currents will use the project's workers value. Since it is not defined, Currents will fall back to the global workers value.
Re-running Only Failed Tests
Orchestrated reruns use pwc-p discover with --last-failed (or flags from the playwright-last-failed action) to build the filtered test list, then pwc-p run with --pwc-discovery-file.
See Orchestrated runs for the full implementation details.
Limitations and Nuances
Orchestration works on a file level — it balances test files (rather than individual tests).
Batch Size needs to manually set to 1 for Fully Parallel Mode in order to correctly balance your machines. We will improve this in a future update.
Playwright Project dependencies is not supported — if projects depend on one another, orchestration will not consider the dependencies. As a workaround, run the dependencies in the desired order explicitly by defining separate CI steps with
--project <name>specification.Global Setup and Teardown. An orchestrated execution runs
playwrightmultiple times. Beware that global setup or teardown routines run for each invocation ofplaywright.
Next Steps
Use Cloud Spot Instances to reduce your CI bills by 90%
Last updated
Was this helpful?