Skip to content

Implement pest --record command for browser test generation#222

Open
J87NL wants to merge 6 commits into
pestphp:5.xfrom
J87NL:feature/browser-recorder
Open

Implement pest --record command for browser test generation#222
J87NL wants to merge 6 commits into
pestphp:5.xfrom
J87NL:feature/browser-recorder

Conversation

@J87NL
Copy link
Copy Markdown

@J87NL J87NL commented May 24, 2026

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/.

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.

Pest-browserrecorder-demo.mp4

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.

J87NL added 6 commits May 24, 2026 14:56
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
…neration into a dedicated Laravel script, and fix various recorder issues
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