Laravel Expectations Plugin for Pest


April 6th, 2023

Laravel Expectations Plugin for Pest

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();
test('user can edit a post', function(){
$user = User::factory()->create();
expect($user)->toBeAbleTo('edit', $post);
test('home is rendered', function () {
$response = get('/home');

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.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.