Laravel 11 + Pest — Writing Tests That Don't Slow Down Yo...
Blog
Back to Blog

Laravel 11 + Pest — Writing Tests That Don't Slow Down Your Releases

Ignacio Amat Ignacio Amat
3 min read
Terminal showing successful execution of Pest tests in a Laravel 11 project

Terminal showing successful execution of Pest tests in a Laravel 11 project

Table of Contents

In many teams, testing is seen as a “necessary evil” that slows down development. “We don’t have time for tests, we need to ship now.” As a Senior Full Stack developer, my response is always the same: you don’t have time not to test.

With Laravel 11 and Pest, testing has gone from being a burden to being a speed tool. Here’s my strategy for maintaining quality without slowing down deployment.

Why Pest?

Pest is not just “PHPUnit with pretty syntax.” It’s a mindset shift. The functional syntax makes tests much more readable and, therefore, easier to maintain.

A test in Pest reads almost like natural language:

it('allows a premium user to download reports', function () {
    $user = User::factory()->premium()->create();

    $this->actingAs($user)
        ->get('/reports/download')
        ->assertStatus(200);
});

My Testing Pyramid in 2026

Not all tests are worth the same. To maximize the ROI of the time invested, I follow this structure:

1. Feature Tests (60%)

This is where I focus most. They test complete functionality from the user’s or API’s perspective. If the Feature Test passes, I know the business is safe. Laravel makes it incredibly easy with its HTTP and authentication helpers.

2. Unit Tests (30%)

For complex logic, calculations, or isolated services. They are ultra-fast and allow me to test all edge cases of a function without touching the database.

3. Architecture Tests (10%)

One of my favorite features of Pest. They allow you to ensure the team follows architectural rules automatically:

arch('globals')
    ->expect(['dd', 'dump', 'var_dump'])
    ->not->toBeUsed();

arch('app')
    ->expect('App\Models')
    ->toOnlyBeUsedIn('App\Repositories');

AI-Augmented Testing

This is where the 2026 factor comes in. I use Claude Code to generate the “scaffold” for the tests.

My workflow:

  1. Write the feature logic.
  2. Ask Claude: “Read this controller and generate the necessary feature tests covering success, failed validation, and permission cases”.
  3. Review and adjust the generated tests.

This eliminates 80% of the repetitive work of writing tests.

The CI/CD Pipeline: The Ultimate Truth

No code reaches main if the tests don’t pass. I use GitHub Actions to run the Pest suite on every PR. If a test fails, the deployment is blocked. This allows me to sleep peacefully knowing I haven’t broken critical functionality in a Friday afternoon release.

Conclusion

Testing with Laravel 11 and Pest is not an obstacle; it’s the life insurance for your product. It allows you to refactor with confidence and constantly deliver value.

If you want me to help you implement a solid testing strategy in your Laravel project or need a senior who takes quality seriously, let’s talk.

Related articles

Looking for a full stack developer?

Available for remote positions, contracts, and technical collaborations. Let's talk about how I can contribute to your team.

Get in touch

Tell me about the position or project

Tell me the type of position, your team's stack, and if you have a start date in mind. I respond within 24 hours.

0/500
Hire me