pestphp/pest-plugin-parallel
Official parallel testing plugin for Pest. Run your test suite concurrently across CPU cores to speed up feedback, with simple configuration and CLI options. Ideal for large projects and CI pipelines looking to reduce test runtime.
Install the plugin via Composer: composer require pestphp/pest-plugin-parallel --dev. Run your tests with pest --parallel—no configuration required. By default, it spawns one process per CPU core and splits test files evenly. Your first real-world use case: running a 5-minute Laravel feature test suite down to ~1.5 minutes in CI, especially for I/O-heavy or database-bound tests. Just run php artisan test --parallel (Laravel) or pest --parallel (plain Pest) in your terminal.
--steps=N to specify how many batches to split tests into (e.g., --steps=3 for 3 runners), helpful when test files vary widely in runtime.php artisan test --parallel—Laravel automatically handles DB connection isolation (each process gets a unique DB_CONNECTION suffix like testing-1, testing-2) and environment cleanup.Pest\Parallel\Events\JobStarted or JobFinished to add logging, metrics, or bootstrap logic (e.g., seeding per-process test databases).PARALLEL_TESTS=1 as an environment variable to force single-process execution while keeping other --parallel flags intact.--stop-on-failure to catch the first issue, then re-run that single test file with pest path/to/file_test.php to debug.--parallel doesn’t auto-isolate DB state—ensure you’re using Laravel’s RefreshDatabase (not DatabaseTransactions) or manually set DB_CONNECTION=testing-{$processId}.pcov (e.g., pest --parallel --coverage --coverage-driver=pcov) or avoid coverage in CI parallel runs.putenv(), static properties, or file-based caches (e.g., without unique per-process paths like /tmp/pest-$$-cache) will cause race conditions. Always scope globals to $_SERVER, process-specific temp directories, or use dependency injection.How can I help you explore Laravel packages today?