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
Pest Plugin Route Testing

Pest Plugin Route Testing Laravel Package

spatie/pest-plugin-route-testing

Pest plugin for Laravel that automatically tests all your app’s GET routes. Run a single test to assert responses are successful, redirects, forbidden, not found, etc. Filter routes by pattern and provide models for route model bindings via bind().

View on GitHub
Deep Wiki
Context7

Make sure all routes in your Laravel app are ok

Frequently asked questions about Pest Plugin Route Testing
How do I test all GET routes in my Laravel app with this package?
Use `routeTesting('all GET routes')->assertSuccessful()` in a Pest test file. The package automatically skips model-binding routes by default, but you can include them with the `bind()` method. No additional configuration is needed for basic usage.
Can I test specific routes like API endpoints or admin-only paths?
Yes, use the `include()` method to target specific routes, like `routeTesting()->include('admin*')->assertSuccessful()`. This works for web routes, API endpoints, and any named routes in your `routes/web.php` or `routes/api.php`.
Does this package support Laravel 9 or older versions?
The package explicitly supports Laravel 10+ as of 2025. While it may work on Laravel 9, Spatie does not guarantee backward compatibility. Check the [GitHub releases](https://github.com/spatie/pest-plugin-route-testing/releases) for updates.
How do I handle routes with model bindings (e.g., `user/{user}`)?
By default, the package skips model-binding routes. To test them, use `bind('user', User::factory()->create())` before assertions. This injects a test model, ensuring the route resolves correctly without requiring real database records.
Will this package slow down my CI pipeline if I test hundreds of routes?
Testing all routes can add overhead, but you can mitigate this by scoping tests (e.g., `include('checkout*')`) or running tests in parallel with Pest’s `--parallel` flag. For large apps, prioritize critical paths and exclude flaky routes with `exclude()`.
Can I validate POST, PUT, or DELETE routes with this package?
The package defaults to testing GET routes only. To test other methods, explicitly include them using `routeTesting()->methods(['POST', 'PUT'])->assertSuccessful()`. However, note that it doesn’t validate request payloads—only HTTP status codes.
How do I handle routes that require authentication (e.g., `actingAs`)?
Use Laravel’s `actingAs()` or `withoutMiddleware()` in your test setup before calling `routeTesting()`. For example: `actingAs(User::factory()->create())->then(fn() => routeTesting()->assertSuccessful())`. This ensures auth-required routes are tested correctly.
Are there alternatives to this package for route testing in Laravel?
Yes, alternatives include Laravel’s built-in `Route::getRoutes()` for manual testing or packages like `laravel-shift/route-listener` for dynamic route validation. However, this package integrates seamlessly with Pest and provides a fluent API for assertions like `assertRedirect()` or `assertForbidden()`.
How do I exclude specific routes from testing (e.g., webhook endpoints)?
Use the `exclude()` method to skip routes by name or pattern, like `routeTesting()->exclude('webhooks*')`. This is useful for routes that don’t need validation (e.g., Stripe webhooks) or are tested via end-to-end flows.
Can I use this package to test JSON API responses or validate response payloads?
No, this package focuses on HTTP status codes and basic assertions (e.g., redirects, forbidden). For JSON schema validation or payload testing, pair it with tools like `spatie/laravel-array-validation` or Laravel’s `assertJson()` in manual tests.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport