New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

dex/pest-plugin-laravel-tester

Pest plugin to test Laravel components
295 1

Larablocks Analysis

dex/pest-plugin-laravel-tester works with Laravel 13 (latest release 5.0.0, Sep 2, 2026).

Promising: maintained and up to date, meets 2 of 4 checks; not yet widely used.

  • Works with Laravel 13, the current version
  • Released in the last 12 months (Sep 2, 2026)
  • 10 downloads a month (needs 10,000)
  • 1 GitHub star (needs 100)

State

Actively maintained
  • Last stable release: Sep 2, 2026.
  • 3 releases in the last 12 months.
  • First released: Aug 23, 2024.
  • Monthly downloads: 10, up 100% from six months ago.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 2, 2026.

Install
composer require dex/pest-plugin-laravel-tester
Latest Version:5.0.0
PHP:^8.4|^8.5
Laravel:13
License:MIT
Last Updated:Oct 1, 2026
Links: GitHub  ·  Packagist
Maintainer: edersoares

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

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

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

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

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

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

Pest Plugin Laravel Tester is open-sourced software licensed under the MIT license.

Alternatives to dex/pest-plugin-laravel-tester

pestphp/pest

The elegant PHP Testing Framework.

115,104,770 11,795
orchestra/pest-plugin-testbench

Pest plugin for Testbench

93,883 5
erikgaal/pest-plugin-sharding

Pest Plugin to split tests into multiple runs

616,586 2
nekofar/pest-plugin-slim

The Pest Slim Plugin

18,483 5
alleyinteractive/pest-plugin-wordpress

WordPress Pest Integration

6,140 27

Version History

Version Released PHP License
5.0.0 ^8.4|^8.5 MIT
4.1.0 ^8.4|^8.5 MIT
4.0.0 ^8.4 MIT
3.0.0 ^8.2 MIT
2.1.0 ^8.1 MIT