laravel/browser-kit-testing
Fluent BrowserKit-style testing for Laravel: make HTTP requests, follow routes, fill forms, and assert response content with simple methods like visit, see, and dontSee. Install as a dev dependency and extend Laravel\BrowserKitTesting\TestCase.
visit(), see(), click(), type()), which aligns well with Laravel’s testing philosophy. It abstracts away low-level HTTP interactions, making tests more readable and maintainable.actingAs(), withoutMiddleware()), reducing friction in adoption.json(), seeJson(), seeJsonStructure), making it versatile for modern Laravel applications with hybrid frontends/backends.Laravel\BrowserKitTesting\TestCase) and no additional configuration, reducing integration effort.TestCase can be gradually migrated without breaking changes, as the API is largely compatible.--dev), ensuring it doesn’t bloat production and can be easily removed if not needed.BrowserKit (Symfony’s HTTP client) lacks JavaScript execution, which may require pairing with tools like Laravel Dusk or Pest for complex frontend tests.DatabaseTransactions). Best used for feature/integration tests.TestCase?
Migration effort is minimal, but audit for deprecated methods (e.g., assertResponseOk() vs. assertOk()).actingAs(), withoutMiddleware(), and session manipulation.seeJsonStructure, seeJsonEquals).BrowserKit, which is lightweight but lacks JS execution. For SPAs or complex frontend logic, pair with Laravel Dusk or Playwright.DatabaseTransactions and RefreshDatabase traits for isolated tests.assertResponseOk() → assertOk()).TestCase class to extend Laravel\BrowserKitTesting\TestCase.visit() instead of get()).see() instead of assertContains()).test() vs. public function test()). Prefer one testing framework per project.seeJsonStructure) for consistency.withoutMiddleware() sparingly).laravel/browser-kit-testing for security patches (MIT license allows forks if needed).BrowserKit internals.BrowserKit is fast for server-side tests but not optimized for parallel execution. For large test suites, consider:
--parallel flag.TestCase or Pest for those).see()/dontSee() assertions are case-sensitive and may fail due to whitespace or HTML structure changes. Use seeInOrder() for strict sequences.seeJsonStructure) can be brittle if the API response schema changes frequently.withoutMiddleware()) may pass locally but fail in production due to missing auth/validation.withSession()) can cause flaky tests. Use refreshDatabase() or DatabaseTransactions to isolate tests.get()/post() to visit()/press().BrowserKit limitations (no JS, no cookies by default).How can I help you explore Laravel packages today?