Laravel Packages

Laravel Expectations Plugin for Pest

Published
Laravel Expectations Plugin for Pest image

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.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article