PHPackages                             hansonxyz/laravel-headless-browser-tester - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. hansonxyz/laravel-headless-browser-tester

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

hansonxyz/laravel-headless-browser-tester
=========================================

Debug Laravel routes using a headless browser - captures response, console errors, XHR requests, DOM state, and screenshots

02JavaScript

Since Dec 9Pushed 5mo agoCompare

[ Source](https://github.com/hansonxyz/laravel-headless-browser-tester)[ Packagist](https://packagist.org/packages/hansonxyz/laravel-headless-browser-tester)[ RSS](/packages/hansonxyz-laravel-headless-browser-tester/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Headless Browser Tester
===============================

[](#laravel-headless-browser-tester)

Debug Laravel routes using a headless browser. Captures HTTP response, JavaScript console output, XHR requests, DOM state, cookies, storage, and screenshots. Supports authenticated user testing and async JavaScript evaluation.

Installation
------------

[](#installation)

```
composer require hansonxyz/laravel-headless-browser-tester:@dev
```

The package is currently in development and requires the `@dev` stability flag.

The package auto-discovers via Laravel's package discovery.

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10, 11, or 12
- Node.js (for Playwright)

Playwright and Chromium are automatically installed on first run.

Usage
-----

[](#usage)

```
# Basic route test
php artisan browser:test /dashboard

# Test as authenticated user (by ID)
php artisan browser:test /admin --user=1

# Test as authenticated user (by email/username)
php artisan browser:test /admin --user=admin@example.com

# Capture everything
php artisan browser:test /page --full

# Take a screenshot
php artisan browser:test /page --screenshot-path=/tmp/shot.png

# Mobile screenshot
php artisan browser:test /page --screenshot-path=/tmp/mobile.png --screenshot-width=mobile
```

Options
-------

[](#options)

OptionDescription`--user=`Test as specific user ID (numeric) or username (string)`--install-middleware`Install the authentication middleware`--no-body`Suppress response body output`--follow-redirects`Show full redirect chain`--headers`Display response headers`--console`Display all console output`--xhr-list`List XHR/fetch requests`--xhr-dump`Full XHR request details`--input-elements`List form inputs`--cookies`Display cookies`--storage`Display localStorage/sessionStorage`--expect-element=`Fail if element not found`--dump-element=`Extract element HTML`--dump-dimensions=`Add layout dimensions to matching elements`--wait-for=`Wait for element before capture`--eval=`Execute async JavaScript (supports await)`--post=`Send POST request`--timeout=`Navigation timeout (default: 30000)`--screenshot-path=`Save screenshot`--screenshot-width=`Width: mobile (375), tablet (768), desktop (1920), or px`--full`Enable all display optionsUser Authentication
-------------------

[](#user-authentication)

The `--user` option allows testing routes as an authenticated user. This requires the `HeadlessBrowserTesterAuth` middleware.

### Automatic Installation

[](#automatic-installation)

```
php artisan browser:test --install-middleware
```

This will:

1. Create `app/Http/Middleware/HeadlessBrowserTesterAuth.php`
2. Register the middleware in your application (Laravel 10 Kernel.php or Laravel 11+ bootstrap/app.php)

### Manual Installation

[](#manual-installation)

If automatic installation doesn't work for your setup, create the middleware manually:

```
// app/Http/Middleware/HeadlessBrowserTesterAuth.php
