Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Browser Laravel Package

zenstruck/browser

A Laravel-friendly browser testing toolkit built on Symfony BrowserKit and Panther. Easily crawl pages, click links, submit forms, assert on HTML, and drive real headless browsers—great for end-to-end tests and fluent, expressive UI assertions.

View on GitHub
Deep Wiki
Context7

A fluent interface for your Symfony functional tests.

Frequently asked questions about Browser
Can zenstruck/browser replace Laravel’s Dusk for JavaScript testing?
No, it cannot fully replace Dusk. While zenstruck/browser includes a PantherBrowser for headless testing, Dusk is specifically optimized for Laravel with ChromeDriver integration, debugging tools, and Laravel-specific assertions. PantherBrowser adds complexity (Symfony dependencies) without Dusk’s Laravel-native features.
How does zenstruck/browser compare to Laravel’s Pest/PHPUnit assertions like `assertSee` or `assertStatus`?
It offers a fluent, chainable syntax (e.g., `->assertSeeIn()->assertNotSeeElement()`) for more expressive tests, but duplicates core functionality. If you prefer method chaining over Pest’s `test()->assert` style, this package provides a cleaner alternative for complex assertions. For simple checks, Laravel’s built-ins are sufficient.
Will zenstruck/browser work with Laravel 10+ and PHP 8.2+?
The package is actively maintained for Symfony 6.x, which aligns with Laravel 10’s PHP 8.2+ requirements. However, Laravel’s testing stack evolves independently, so check the [GitHub issues](https://github.com/zenstruck/browser/issues) for Laravel-specific compatibility notes. No major conflicts are reported yet, but Symfony’s BrowserKit may require adjustments for Laravel’s HTTP layer.
Do I need Symfony components (e.g., Panther, DomCrawler) to use zenstruck/browser in Laravel?
Yes. The package relies on Symfony’s BrowserKit and Panther for core functionality. Installing `zenstruck/browser` pulls these dependencies, increasing bundle size and requiring ChromeDriver for PantherBrowser. If you’re not already using Symfony, this adds unnecessary complexity compared to Laravel’s Dusk or Pest.
How do I integrate zenstruck/browser with Laravel’s existing test suite (Pest/PHPUnit)?
Add the PHPUnit extension via `phpunit.xml` and replace assertions with fluent syntax (e.g., `->assertSeeIn()` instead of `assertSee()`). For KernelBrowser (API testing), wrap Laravel’s HTTP layer manually, but this is less straightforward than using Laravel’s `HttpTests` or `Http::fake()`. Avoid mixing styles to prevent confusion.
Does zenstruck/browser support screenshot capture and error debugging like Dusk?
Yes, the PHPUnit extension auto-saves HTML snapshots, screenshots (for PantherBrowser), and JS console logs on test failures. However, Dusk’s debugging tools (e.g., interactive debug mode) are more polished. This feature is useful for CI debugging but not a full replacement for Dusk’s developer experience.
Can I use zenstruck/browser for API contract testing instead of Laravel’s Http::fake()?
Partially. KernelBrowser’s HTTP methods (`get()`, `post()`) mimic contract testing, but Laravel’s `Http::fake()` is more mature and integrates seamlessly with Laravel’s routing and middleware. Use KernelBrowser only if you need Symfony’s DomCrawler for response parsing or fluent assertions on raw HTML.
What’s the performance impact of PantherBrowser vs. Laravel’s Dusk in CI?
PantherBrowser is slower than Dusk because it relies on Symfony’s Panther for JS rendering, which requires ChromeDriver and full page loads. Dusk is optimized for Laravel with lazy loading and parallelization. Benchmark your tests: PantherBrowser may double execution time in CI, while Dusk remains stable.
Are there Laravel-specific alternatives to zenstruck/browser for fluent assertions?
Yes. Consider `spatie/laravel-testing-tools` for Laravel-native helpers or Pest’s `test()`-`assert` syntax. For DomCrawler-like parsing, use `simplehtmldom/simple-html-dom` or Laravel’s `Html` facade. If you need fluent chaining, wrap Laravel’s assertions in a custom trait instead of adding Symfony dependencies.
How do I configure zenstruck/browser to work with Laravel’s authentication (actingAs)?
KernelBrowser doesn’t natively support Laravel’s `actingAs()`. You’ll need to manually set cookies or headers via Symfony’s `Client` or use a middleware adapter. For seamless auth testing, stick with Laravel’s `HttpTests` or Dusk, which handle `actingAs()` out of the box. This is a common gap when mixing Symfony and Laravel components.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views