laravel/browser-kit-testing
Fluent BrowserKit-style testing for Laravel apps: make HTTP requests, navigate pages, assert response content, and interact with forms in functional tests. Install as a dev dependency and extend Laravel\BrowserKitTesting\TestCase to get started.
TestCase, and database testing traits (DatabaseTransactions, RefreshDatabase), making it a natural fit for Laravel applications.Laravel\BrowserKitTesting\TestCase—reducing friction for adoption.TestCase, existing tests require no modifications beyond the base class update.TestCase may already suffice, making this package redundant.HttpTests or Dusk? If so, migration effort should be assessed.HttpTests or PestPHP).RefreshDatabase, Migrations).Illuminate\Foundation\Testing\TestCase or HttpTests.// Before
use Illuminate\Foundation\Testing\TestCase;
// After
use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
HttpTests assertions with BrowserKit methods (e.g., see() instead of assertSee()).actingAs().TestCase.BrowserKitTesting\TestCase.see() instead of assertSee()).--parallel).laravel).--parallel (no inherent blocking).DatabaseTransactions) help isolate tests.HttpTests for API-heavy tests, reserve BrowserKit for UI/form testing.HttpTests).| Failure Scenario | Root Cause | Mitigation |
|---|---|---|
| Test flakiness | Race conditions in BrowserKit requests | Use DatabaseTransactions, avoid shared state. |
| Assertion mismatches | HTML changes not reflected in tests | Update tests before production deploys. |
| Middleware conflicts | WithoutMiddleware not applied |
Explicitly use withoutMiddleware() or trait. |
| Session/auth issues | actingAs() not persisting |
Ensure session drivers are configured. |
| File upload failures | attach() path issues |
Use absolute paths or storage_path(). |
visit()->see()->click()).type(), check()).HttpTests instead).see(), actingAs(), seeJson()).How can I help you explore Laravel packages today?