soyhuce/pest-plugin-laravel

Custom extensions for Laravel integration into Pest
2,932
Install
composer require soyhuce/pest-plugin-laravel
Latest Version:1.1.0
PHP:^8.4
License:MIT
Last Updated:Feb 27, 2026
Links: GitHub  ·  Packagist
Maintainer: SoyHuCe

Pest plugin for Laravel development

Latest Version on Packagist GitHub Tests Action Status GitHub static analysis Action Status GitHub Pint Action Status Total Downloads

Installation

You can install the package via composer:

composer require soyhuce/pest-plugin-laravel --dev

Usage

Expectations

  • toBeModel expects that the value matches current model
expect($model)->toBeModel($expectedModel)
  • toBeCollection expects that the collection matches current collection
expect($collection)->toBeCollection(new Collection([1,2,3]));
/// Expected collection can be given as array
expect($collection)->toBeCollection([1,2,3]);

Keys and order of the collections are checked and must match.

  • toBeCollectionCanonicalizing expects that the collection matches current collection, ignoring order
expect($collection)->toBeCollectionCanonicalizing(new Collection([1,2,3]));
/// Expected collection can be given as array
expect($collection)->toBeCollectionCanonicalizing([3,1,2]);

Keys of the collections are checked and must match.

  • toBeAbleTo expect that the autenticatable can perform the given action
expect($user)->toBeAbleTo('update', $post);

Data expectations : require spatie/laravel-data package

  • toBeData expects that the value matches current data object
expect($data)->toBeData(new UserData(['name' => 'John Doe']));
  • toBeDataCollection expects that the collection matches current data collection
expect($dataCollection)->toBeDataCollection(new UserDataCollection([
    new UserData(['name' => 'John Doe']),
    new UserData(['name' => 'Jane Doe']),
]));

// Expected collection can be given as array
expect($dataCollection)->toBeDataCollection([['name' => 'John Doe'], ['name' => 'Jane Doe']]);

Related Packages

brickx/pest-plugin-money

A Pest plugin to work with popular money libraries

522 1
shipfastlabs/pest-plugin-evals

A PestPHP plugin for evaluating Laravel AI SDK agents with LLM-as-judge, semanti...

3 12
defstudio/pest-plugin-laravel-expectations

A plugin to add laravel tailored expectations to Pest

620,458 98
jhwelch/pest-plugin-laravel-migrations

A Pest PHP plugin that lets you test Laravel migrations with a simple and straig...

2 0
pestphp/pest-plugin-drift

The Pest Drift Plugin

5,574,600 74