Laravel Expectations Plugin for Pest
Published on by Paul Redmond
Pest Laravel Expectations is a Pest plugin that adds Laravel-specific expectations to the testing ecosystem:
it('can check model exists', function(){ $user = User::factory()->create(); expect($user)->toExist();}); test('user can edit a post', function(){ $user = User::factory()->create(); expect($user)->toBeAbleTo('edit', $post);}); test('home is rendered', function () { $response = get('/home'); expect($response)->toBeSuccessful();});
This plugin includes different expectations across the following Laravel features:
- Authentication
- Collections
- Database
- Exceptions
- Models
- Response
- Storage
- Time
- Views
To get started, check out the documentation for a complete list of expectations with examples. Also, you can get the full source code at defstudio/pest-plugin-laravel-expectations.