Implement pest --record command for browser test generation#221
Closed
J87NL wants to merge 12 commits into
Closed
Conversation
* chore: pin GitHub Actions to commit SHAs * chore: pin GitHub Actions to commit SHAs
Add --server/--migrate-fresh/--seed flags and auto-detect login sequences - Record.php: add --server (starts `php artisan serve`), --env, --migrate-fresh, --seed options - TestGenerator: strip password form fills and inject actingAs(factory()) automatically; pass $actingAs when --acting-as is set - Locator: use Selector::getByLabelSelector for textbox/searchbox/combobox roles - README: document --server (env mismatch problem), expand --acting-as section, fix example output
…using factory session, remove login sequence auto-detection, add RECORDING.md
…dex bug in EventSanitizer
…neration into a dedicated Laravel script, and fix various recorder issues
…s to the recorder
**As more code (and tests) gets written by AI, (browser)tests matter more than ever. Not just as a safety net, but as the source of truth.** `vendor/bin/pest --record` (or `php artisan test --record`) opens a real browser, lets you click through your app, fill and save forms, close the browser, give the test a name and Pest writes a ready-to-run test to tests/Browser/. ```bash vendor/bin/pest --record --visit=/checkout vendor/bin/pest --record --auth --migrate-fresh --seed --visit=/dashboard vendor/bin/pest --record --url=https://pestphp.com ``` This implementation is based on my POC https://github.com/ComfyCodersBV/laravel-pest-recorder which I talked about with Nuno at Laracon EU. https://github.com/user-attachments/assets/6c39b3e7-89aa-4131-92b7-3ed8400f5859 What's in here: - Full record flow: auto-starts Laravel test server, opens Playwright recorder, you can navigate, fill forms, make assertions. - Event sanitizer: deduplicates fills, removes noise, cleans up navigations - Code generator: maps Playwright events to Pest Browser format - Auth support: `--auth` or `--user` bootstraps a factory user with a session cookie; generated test uses actingAs(). Built in auth for Laravel included, manual override option possible for other frameworks or extended authentication. - RECORDING.md usage guide - Most original options of `playwright codegen` supported & more like the `--url=...` flag.
Member
|
Can you target 5.x branch as i would like to make this "part" of pest 5? |
Author
|
Opened a new PR with the 5.x-target branch at #222 |
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.
As more code (and tests) gets written by AI, (browser)tests matter more than ever.
Not just as a safety net, but as the source of truth.
vendor/bin/pest --record(orphp artisan test --record) opens a real browser, lets you click through your app, fill and save forms, close the browser, give the test a name and Pest writes a ready-to-run test to tests/Browser/.This implementation is based on my POC https://github.com/ComfyCodersBV/laravel-pest-recorder which I talked about with Nuno at Laracon EU.
Pest-browserrecorder-demo.mp4
What's in here:
--author--userbootstraps a factory user with a session cookie; generated test uses actingAs(). Built in auth for Laravel included, manual override option possible for other frameworks or extended authentication.playwright codegensupported & more like the--url=...flag.