Skip to content

fix: forward --browser, --trace, --dark and --light to parallel workers - #308

Open
MoogyG wants to merge 1 commit into
pestphp:5.xfrom
MoogyG:fix/forward-browser-options-to-parallel-workers
Open

MoogyG wants to merge 1 commit into
pestphp:5.xfrom
MoogyG:fix/forward-browser-options-to-parallel-workers

Conversation

@MoogyG

@MoogyG MoogyG commented Nov 9, 2026

Copy link
Copy Markdown

What:

  • Bug Fix
  • New Feature

Description:

Under --parallel, the workers ignore --browser, --trace, --dark and --light: they run Chrome, record no trace and render in light mode, whatever the options of the run. Nothing fails, so a --browser safari --parallel run passes while no test ran in WebKit.

The run does parse these options, but its workers are started with PHPUnit's arguments only (--cache-directory, --no-output…), so Plugin::handleArguments() never sees them in a worker.

Reproduction, with a test that records Playwright::defaultBrowserType() and Playwright::shouldTrace() from inside a worker, then fails:

Command Browser in the workers Trace of the failed test
pest --browser safari --trace Safari saved
pest --browser safari --trace --parallel Chrome none
same, with this PR Safari saved

The fix follows what Pest's Snapshot plugin does for --update-snapshots: when the run is parallel, handleArguments() hands the browser options to the workers through Parallel::setGlobal(), and a worker appends them to its own arguments before parsing them, so they go through the same code as in a serial run. pest()->browser() in Pest.php still takes precedence, as it is loaded after the arguments are handled. The options rejected under --parallel (--headed, --debug, --diff, --slow-mo) are not forwarded.

The new tests in tests/Unit/Plugin/ParallelPluginTest.php hand the arguments of a parallel run to the plugin, then those of a worker, and check the browser, the trace and the color scheme the worker ends up with. Checked end to end on a Laravel app as well, under Chrome and WebKit.

🤖 Generated with Claude Code

Under --parallel, the workers only receive PHPUnit's arguments, so they
silently ran Chrome without traces and in light mode, whatever the
options of the run. The run now hands them to its workers through
Parallel::setGlobal(), as the Snapshot plugin does for
--update-snapshots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant