pbmedia/laravel-browser-kit-macro
pbmedia/laravel-browser-kit-macro adds useful macros to Laravel's Browser Kit, extending its fluent HTTP testing API with convenient helpers and assertions so you can write cleaner, more expressive feature tests for Laravel applications.
Architecture fit. The package is a thin, single-purpose dev-time shim: a macro (typically a trait registered in setUp() or via a service provider) that re-exposes Laravel 5.3's BrowserKit-style test API — visit(), see(), click(), type(), press(), seePageIs() — on modern Illuminate\Foundation\Testing\TestCase classes. It has no runtime footprint, no container bindings, no queue/route/config surface, and no production blast radius. Architecturally it is a compatibility bridge, and should be treated as scaffolding, not as an architectural dependency. Release 5.9.0 changes nothing here: the diff is a PHP 8.5 compatibility bump, not a change in scope or design posture.
Integration feasibility. Low technical effort: composer require --dev, register the macro, run the affected test subset. The real work is verification, not integration. Three things need to be confirmed against our stack before committing: (1) whether the package pulls laravel/browser-kit-testing transitively or vendors the logic itself, since that first-party package is deprecated and is the actual compatibility anchor; (2) whether it supports our PHPUnit major (PHPUnit 10/11 changed lifecycle and removed annotation-era assumptions that macro registration in setUp() can trip over) — 5.9.0 confirms PHP 8.5 support but says nothing about PHPUnit; (3) whether Symfony browser-kit and dom-crawler remain installable at our pinned Symfony major.
Technical risk. Adoption signal remains essentially absent: 2 stars, 0 dependents, effectively a single-maintainer project. The 5.9.0 release is a modest positive counter-signal: a real code change (PHP 8.5 support) merged from an external contributor (@realpascalbotjet, PR #12), which implies CI that actually runs on at least one current runtime. That downgrades "unmaintained body with fresh metadata tag" — the worst-case read in the prior assessment — to "sporadically maintained by one person, accepts community patches." It does not upgrade it to "field-validated." There is still no evidence of anyone else running this against the edge cases we will hit, and no published PHPUnit/Symfony matrix. The directional risk is unchanged: the macro preserves a testing style Laravel deliberately removed, so we would be coupling our test suite's forward-compatibility to a package whose entire purpose is backward-compatibility. Note also that a PHP 8.5 patch is the cheapest possible form of maintenance — it keeps the package installable without addressing the deprecated-API direction of travel.
Key questions.
laravel/browser-kit-testing, and if so, is that dependency pinned to a fork or to the abandoned original?TPM recommendation. Unchanged in substance: the macro's idea is worth using; the dependency probably is not. Vendor the trait into tests/Support/ with a header comment pointing at the origin (and noting the 5.9.0 SHA reviewed). That preserves the migration unblock while removing supply-chain, abandonment, and SBOM exposure entirely — at approximately the same engineering cost as integrating the package. 5.9.0 slightly reduces the probability of a mid-upgrade abandonment surprise but does not reduce the cost of being wrong, and does not touch the PHPUnit/Symfony compatibility unknowns that are the actual blockers.
Stack fit. Dev-only dependency (require-dev), applicable to Laravel 8–12 projects with PHPUnit or Pest, used exclusively during composer test / CI. It changes nothing about deploy artifacts, image size, runtime dependency graph, or infrastructure. That makes it one of the few dependency decisions that can be made by the test-infrastructure owner without platform sign-off — and should be scoped that way in the decision record.
Migration path. Two viable directions, and the choice should be made explicitly rather than by default:
visit()/see()/click() suite stays green while the framework underneath is upgraded. This deliberately decouples "upgrade Laravel" from "rewrite tests," which is usually the right call when the upgrade is time-boxed and the test rewrite is not.$this->get(), assertSee(), assertRedirect(), withSession(), actingAs(); escalate to Dusk/Playwright only where real browser interaction is required. Set a dated target for this; a bridge with no expiry becomes permanent architecture.Compatibility. Verify before merge: composer constraints against our locked Laravel and PHPUnit; absence of conflicts with laravel/dusk or pestphp/pest; PHPUnit 10+ attribute support if we're past v9; Symfony BrowserKit/DomCrawler availability at our Symfony major; and method-name collisions between the macro's additions and newer TestCase/MakesHttpRequests methods (these surface as confusing runtime failures, not install errors, so they need a deliberate smoke test). If we pin rather than vendor, pin to 5.9.0 specifically and re-verify — a PHP 8.5 patch can move the transitive dependency floor, so re-read composer.lock after the bump rather than assuming it is inert.
Sequencing.
->visit(, ->see(, ->click(, ->type(. Size the affected test count and the CI minutes they represent.composer.lock reviewed, added to the dependency-review checklist).Maintenance. Near-zero runtime maintenance, non-zero dependency hygiene. A low-adoption, effectively single-maintainer package in require-dev still appears in SBOMs and audit output, still requires a justification line in dependency reviews, and can still block a PHPUnit or Symfony major upgrade at exactly the moment we need to move fast. 5.9.0 demonstrates the maintainer will take a compatibility PR, which is mildly reassuring for routine runtime bumps, but the package has no test matrix published for the axes we care about. Vendoring shifts this from "dependency we track" to "code we own," which for a file this size is the lower-cost option.
Support. No vendor. Community-only via GitHub issues with effectively no user base, meaning no one else has hit our failure modes and no one else will answer — though PR #12 shows external patches do land, so contributing an upstream fix is at least nominally viable. Budget for self-support regardless: someone must be able to read the trait and patch it. Assign explicit internal ownership to the test-infrastructure/QA lead and note it in the runbook.
Scaling. Trivially scales as code; the scaling concern is CI economics, not throughput. BrowserKit-style tests boot the full HTTP kernel and crawl the DOM per assertion, which is materially slower per test than Laravel's native HTTP tests. At a few hundred tests that is noise; at a few thousand it is a visible CI-minutes line item and a feedback-loop tax on every PR. Quantify the delta during the spike and cap adoption to the legacy subset — forbid new tests from using the macro.
Failure modes.
BadMethodCallException across the suite at setUp() — loud, at least, but landing on the critical path of an unrelated upgrade. 5.9.0 reduces the PHP-runtime variant of this; the PHPUnit variant is unaddressed.laravel/browser-kit-testing or an older Symfony BrowserKit makes composer update unsatisfiable, which can escalate from "annoying" to "cannot patch a CVE in a dev dependency," blocking security remediation work.TestCase methods shadow or conflict with macro-provided names, yielding failures that look like application bugs.Ramp-up. Effectively zero for engineers who worked in the 5.3 era — an hour with an example test is enough. But for anyone who joined after Laravel 5.4, this is a deprecated API with no current official documentation, and they will be learning it from source. That reverse-ramp cost is the strongest argument for containment: confine the macro to pre-existing tests being carried through the upgrade, convert them on a schedule, and never let it become the documented way to write a new test.
How can I help you explore Laravel packages today?