Add slow motion support for easy debugging - #248
Open
nicoverbruggen wants to merge 2 commits into
Open
Conversation
Ports pestphp#230 to the 5.x branch, which lets users run Playwright's `slowMo` mode, which is very useful to review AI-generated browser tests. Co-authored-by: Peter Elmered <peter@elmered.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Playwright has a
slowMolaunch option that delays each interaction, which is what you want when you are watching a headed run to check that a test does the right things in the right order.At Spatie, we're using more AI to generate browser tests. This way we can run individual tests with
--slow-moand tests tend to play out like they would with real users, who slow down between clicking on buttons, links and interacting with elements on the website.Currently, Pest's browser plugin does not expose this Playwright flag, and a hacky workaround is required to get this to work today.
I looked at prior PRs and found #230, which was created for Pest 4. I've ported this PR and improved for Pest 5.
It adds a
--slow-moflag, optionally with a value in milliseconds, andpest()->browser()->slowMo(250). I've credited the original author of that PR in my first commit, but I've made adjustments in the second that make the argument parsing etc. more in line with the rest of the code of the project.This PR also refuses slow motion under
--parallel, next to headed mode, screenshot diffing and debug assertions. Slow motion is only really useful when you can watch a run, and headed mode is already refused there, so the combination just makes things slower.