- feat: time based sharding by @nunomaduro in #1671
For better shard balance, Pest can distribute tests based on their actual execution time using the --update-shards option. This ensures each shard takes roughly the same wall-clock time, minimizing how long your slowest CI job runs.
Step 1: Generate the timing data by running your full test suite with --update-shards:
./vendor/bin/pest --update-shardsThis runs all tests and records each test class's duration into tests/.pest/shards.json. You can also combine it with --parallel to speed things up:
./vendor/bin/pest --parallel --update-shardsStep 2: Commit tests/.pest/shards.json to your repository. This file is human-readable and looks like this:
{
"timings": {
"Tests\\Feature\\Payments\\StripeCheckoutTest": 1.608,
"Tests\\Feature\\Reports\\SalesReportTest": 2.105,
"Tests\\Unit\\Models\\UserTest": 0.050
},
"checksum": "...",
"updated_at": "2026-04-14T10:30:00+00:00"
}Step 3: When you run --shard and tests/.pest/shards.json exists, Pest automatically uses time-balanced distribution:
./vendor/bin/pest --shard=1/5The output will indicate that time-balanced sharding is active:
Shard: 1 of 5 — 12 files ran, out of 50 (time-balanced).