orchestra/testbench-browser-kit
Adds Laravel BrowserKit testing to Orchestra Testbench for package development. Swap your base test case to Orchestra\Testbench\BrowserKit\TestCase to use fluent visit/see/form APIs in functional tests across supported Laravel versions.
browser-kit-testing with Testbench compatibility, enabling seamless integration into Laravel package development. It aligns with Laravel’s testing ecosystem, leveraging Symfony’s BrowserKit under the hood for HTTP interactions.Orchestra\Testbench\TestCase, preserving existing test structures while adding BrowserKit methods.TestCase), requiring minimal changes to existing test suites. No database migrations, service providers, or config overrides are needed.orchestra/testbench and laravel/browser-kit-testing, both stable and widely adopted. No conflicting dependencies or version conflicts expected.BrowserKit is a headless browser emulator, not a full browser. Tests for JavaScript-heavy UIs (e.g., SPAs, dynamic content) may fail silently or require polyfills.browser-kit-testing.browser-kit-testing over alternatives like laravel/http-tests or pestphp/pest?browser-kit-testing breaking changes)?laravel/browser-kit-testing alone (without Testbench) suffice for our needs?PHPUnit or PestPHP for isolated logic.DatabaseTransactions or DatabaseMigrations traits.pestphp/pest or phpunit/phpunit for assertions.Orchestra\Testbench\TestCase with Orchestra\Testbench\BrowserKit\TestCase in a single test file. Verify compatibility.see(), seeJson()) first.visit(), type(), actingAs()).composer.json under require-dev:
"orchestra/testbench-browser-kit": "^10.0"
TestCase class (handled automatically by Testbench).DatabaseTransactions, WithoutMiddleware).browser-kit-testing (e.g., spatie/laravel-test-factory).TestCase or Http clients (e.g., nunomaduro/collision).withSession() for persistent state.POST/PUT/PATCH requests in Laravel 5.4+.attach() (e.g., __DIR__.'/files/test.jpg').| Phase | Tasks | Dependencies |
|---|---|---|
| Pre-Integration | Audit tests; benchmark performance; align team. | None |
| Pilot | Migrate 1–2 test files; validate assertions. | Testbench installed. |
| Core Migration | Refactor HTTP/API tests to use BrowserKit methods. | Pilot success. |
| Auth/Session | Test actingAs() and withSession() flows. |
Auth system in place. |
| CI/CD | Add test suite to pipelines; set performance budgets. | Pipeline access. |
| Optimization | Parallelize tests; cache responses; address flakiness. | Test suite stability. |
orchestra/testbench-browser-kit and laravel/browser-kit-testing for breaking changes.composer.json to avoid surprises (e.g., ^10.0 for Laravel 12.x).visitRoute() vs. visit()).dd($this->response->getContent()) for inspection.actingAs() and session middleware.->withoutMiddleware().App\Http\Middleware\VerifyCsrfToken is enabled in tests.attach() (e.g., storage_path('test.jpg')).browser-kit-testing questions.How can I help you explore Laravel packages today?