PHPackages                             dex/pest-plugin-laravel-tester - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. dex/pest-plugin-laravel-tester

ActiveLibrary[Framework](/categories/framework)

dex/pest-plugin-laravel-tester
==============================

Pest plugin to test Laravel components

4.1.0(3w ago)11831MITPHPPHP ^8.4|^8.5

Since Aug 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/edersoares/pest-plugin-laravel-tester)[ Packagist](https://packagist.org/packages/dex/pest-plugin-laravel-tester)[ Fund](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L)[ GitHub Sponsors](https://github.com/nunomaduro)[ RSS](/packages/dex-pest-plugin-laravel-tester/feed)WikiDiscussions 3.x Synced 1w ago

READMEChangelog (5)Dependencies (15)Versions (8)Used By (1)

Pest Plugin Laravel Tester
==========================

[](#pest-plugin-laravel-tester)

Test Laravel Eloquent models, relationships, API endpoints and validation rules with near-zero boilerplate using Pest's higher-order syntax.

```
describe('Post', function () {
    beforeEach()->eloquent(Post::class)->endpoint('/api/post');

    test()->toBeCreate();
    test()->toBeUpdate();
    test()->toBeDelete();

    test()->toHaveBelongsToRelation(User::class, 'user');
    test()->toHaveHasManyRelation(Comment::class, 'comments');

    test()->toHaveIndexEndpoint();
    test()->toHaveStoreEndpoint();
    test()->toHaveShowEndpoint();
    test()->toHaveUpdateEndpoint();
    test()->toHaveDestroyEndpoint();

    test()->toValidateRequired('title');
    test()->toValidateMin('title', 10);
    test()->toValidateMax('title', 200);
});
```

Installation
------------

[](#installation)

```
composer require --dev dex/pest-plugin-laravel-tester
```

Add the `Tester` trait to your `tests/Pest.php`:

```
use Dex\Pest\Plugin\Laravel\Tester\Tester;

uses(Tester::class)->in(__DIR__);
```

Eloquent CRUD
-------------

[](#eloquent-crud)

Assert that a model can be created, updated, and deleted using its factory. Soft deletes are detected automatically.

```
describe('Post', function () {
    beforeEach()->eloquent(Post::class);

    test()->toBeCreate();
    test()->toBeUpdate();
    test()->toBeDelete(); // uses assertSoftDeleted() when the model uses SoftDeletes
});
```

Customize the factory state for a specific test:

```
describe('Post', function () {
    beforeEach()->eloquent(Post::class);
    beforeEach()->factory(fn ($factory) => $factory->state(['status' => 'published']));

    test()->toBeCreate()->assertDatabaseHas(Post::class, ['status' => 'published']);
});
```

Relationships
-------------

[](#relationships)

```
describe('Post relationships', function () {
    beforeEach()->eloquent(Post::class);

    test()->toHaveBelongsToRelation(User::class, 'user');
    test()->toHaveHasManyRelation(Comment::class, 'comments');
    test()->toHaveHasOneRelation(Comment::class, 'latestComment');
});

describe('User relationships', function () {
    beforeEach()->eloquent(User::class);

    test()->toHaveHasManyThroughRelation(Comment::class, Post::class, 'comments');
});
```

REST API Endpoints
------------------

[](#rest-api-endpoints)

Assert the full CRUD cycle of an API resource, including HTTP status codes and database state after each operation.

```
describe('Post API', function () {
    beforeEach()->eloquent(Post::class)->endpoint('/api/post');

    test()->toHaveIndexEndpoint();   // GET    /api/post       → 200
    test()->toHaveStoreEndpoint();   // POST   /api/post       → 201 + assertDatabaseCount(1)
    test()->toHaveShowEndpoint();    // GET    /api/post/{id}  → 200
    test()->toHaveUpdateEndpoint();  // PUT    /api/post/{id}  → 200 + assertDatabaseHas
    test()->toHaveDestroyEndpoint(); // DELETE /api/post/{id}  → 200 + assertDatabaseMissing
});
```

When the response wraps data under a key (e.g., Laravel's API resources or pagination):

```
test()->wrap('data')->toHaveIndexEndpoint();
test()->wrap('post')->toHaveShowEndpoint();
```

Transform the payload before sending or the response before asserting:

```
beforeEach()->transformPayload(fn ($data) => collect($data)->except('computed')->all());
beforeEach()->transformResult(fn ($data) => collect($data)->except('computed')->all());
```

Validation
----------

[](#validation)

Each method tests both the `store` (POST) and `update` (PUT) endpoints, asserting a 422 with the appropriate validation error.

```
describe('Post validation', function () {
    beforeEach()->eloquent(Post::class)->endpoint('/api/post');

    test()->toValidateRequired('title');
    test()->toValidateMin('title', 10);
    test()->toValidateMax('title', 200);
    test()->toValidateSize('code', 8);
});
```

License
-------

[](#license)

Pest Plugin Laravel Tester is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance62

Regular maintenance activity

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~99 days

Recently: every ~143 days

Total

8

Last Release

22d ago

Major Versions

2.x-dev → 3.0.02024-12-24

3.x-dev → 4.0.02026-06-30

PHP version history (4 changes)2.0.0PHP ^8.1

3.0.0PHP ^8.2

4.0.0PHP ^8.4

4.1.0PHP ^8.4|^8.5

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/957395?v=4)[Eder Soares](/maintainers/edersoares)[@edersoares](https://github.com/edersoares)

---

Top Contributors

[![edersoares](https://avatars.githubusercontent.com/u/957395?v=4)](https://github.com/edersoares "edersoares (69 commits)")

---

Tags

laravelpestpestphpphpplugintestingunitframeworktestpest

### Embed Badge

![Health badge](/badges/dex-pest-plugin-laravel-tester/health.svg)

```
[![Health](https://phpackages.com/badges/dex-pest-plugin-laravel-tester/health.svg)](https://phpackages.com/packages/dex-pest-plugin-laravel-tester)
```

###  Alternatives

[pestphp/pest

The elegant PHP Testing Framework.

11.6k77.3M24.1k](/packages/pestphp-pest)[defstudio/pest-plugin-laravel-expectations

A plugin to add laravel tailored expectations to Pest

99617.0k9](/packages/defstudio-pest-plugin-laravel-expectations)[pestphp/pest-plugin-browser

Pest plugin to test browser interactions

1344.6M268](/packages/pestphp-pest-plugin-browser)[pestphp/pest-plugin-arch

The Arch plugin for Pest PHP.

4463.1M6.2k](/packages/pestphp-pest-plugin-arch)[pestphp/pest-plugin-stressless

Stressless plugin for Pest

681.1M18](/packages/pestphp-pest-plugin-stressless)[pestphp/pest-plugin-profanity

The Pest Profanity Plugin

10622.1M92](/packages/pestphp-pest-plugin-profanity)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
