Playwright's --shard=i/N splits tests by count and file order. One shard can get a few long spec files and finish minutes after the others while their machines sit idle. With balanced sharding, each shard asks Currents for the recent durations of your spec files and splits the tests so the shards finish at about the same time.
- Splits sharded runs by the last 7 days of recorded spec file durations
- Keeps your CI setup: the same
--shardjobs and the same Playwright config - Every shard computes the same plan, so no test runs twice or gets skipped
- Re-runs keep the split of the attempt before them, so a failed test runs again on its own shard. On GitHub Actions and GitLab 19.3+ they link without extra setup
- Off by default: turn it on with
balancedSharding: true - Available now on Currents cloud with
@currents/playwright2.10.0+ (2.11.0+ for re-runs) and Playwright 1.62+
Turn it on
Set the option in currents.config.ts, so every shard of a build reads the same value:
// currents.config.ts
import { CurrentsConfig } from "@currents/playwright";
const config: CurrentsConfig = {
recordKey: process.env.CURRENTS_RECORD_KEY,
projectId: process.env.CURRENTS_PROJECT_ID,
balancedSharding: true,
};
export default config;
You can also set CURRENTS_BALANCED_SHARDING=true or pass --pwc-balanced-sharding true to pwc. Each shard prints the part of the plan it runs:
Balanced sharding: shard 1/4: 25 tests planned, about 29s (plan 3cacceecf32d)
A project with too little history splits the tests the way Playwright does, and the line says why. Those runs record durations, so balancing starts on a later run without any change.
What to expect
In a replay of 900+ real Playwright sharded runs, balanced sharding shortened the median run by about 15%, and most teams would have seen 10% or more. Results depend on how uneven your suite is: suites with a few long spec files gain the most. These figures are estimates from replaying recorded runs, not measurements of balanced runs. Not every run in the replay was faster, and balanced sharding shortens test time only: CI queueing and runner start-up don't change.
Re-runs link to the attempt before them on GitHub Actions with any CI build ID, and on GitLab 19.3+ with a CI build ID that ends in $CI_PIPELINE_ID-$CI_JOB_RETRY_COUNT (@currents/playwright 2.13.0+). On other CI providers with a custom CI build ID, set CURRENTS_PREVIOUS_CI_BUILD_ID on the re-run. The docs cover the re-run setup and every message a shard can print.
Learn more:
