pestphp/pest-plugin-browser
Pest Plugin for Browser adds browser testing capabilities to Pest, helping you write expressive end-to-end tests for your PHP applications. Part of the Pest ecosystem—see pestphp.com for docs and setup guidance.
Install the plugin via Composer (composer require pestphp/pest-plugin-browser --dev), then run pest --init to scaffold the initial Pest setup if not already done. This plugin enables asynchronous browser interaction testing—ideal for real-time UI validation (e.g., WebSocket-driven Livewire apps or real-time dashboards). First use case: test that a Livewire component emits an event when a user types in an input field—without stubbing or waiting for full page reloads.
browser()->connect() to establish a WebSocket connection to your app (typically the test server started via pest()->beforeEach(fn () => $this->startServer())).browser()->waitForText('Hello') or browser()->emit('event-name', ['data' => 'value']) inside test closures for reactive UI assertions.pestphp/pest-plugin-laravel to leverage Laravel’s testing helpers (e.g., actingAs()) before opening the browser connection.tests/BrowserTest.php (or a base test class), then broadcast events using Browser::emit() or consume them with browser()->on('event', fn (...) => ...).it('updates live chat message', function () {
$user = User::factory()->create();
$this->actingAs($user)->get('/chat');
browser()->connect('ws://localhost:8080/chat')
->emit('message', ['text' => 'Hi!'])
->waitForText('Hi!')
->assertSee('Hi!');
});
ext-sockets and PHP 8.3+—verify this in your environment before installing.defer/async where applicable.browser()->withTimeout(10) if testing slow endpoints.Pest::beforeEach(fn () => $this->app->make('log')->setLogLevel('debug')).Artisan::call('websockets:serve'))—this plugin does not auto-start backend servers.src/ for under-documented features like browser()->broadcast() or onBroadcast().How can I help you explore Laravel packages today?