Get expert guidance in a few days with a Laravel code review

Everything We Know about Pest 3

Published on by

Everything We Know about Pest 3 image

Nuno Maduro was the opening speaker at Laracon US 2024 on Tuesday, unveiling impressive new features for the upcoming Pest v3.0. Pest continues to grow in popularity, being downloaded over 18 million times and is the default testing framework in Laravel as of V11.

Pest v3 takes another important leap forward with three impressive features coming to Pest 3:

  • Task management
  • Architecture Presets
  • Mutation Testing

Let's look at each of these features shared at Laracon US in more detail:

Task Management

Task management lets you track things like assignee, issue number, pull request number, and notes, directly on a test. Tracking tasks allows you to keep a history of work that will always be availabe in your test:

test('some test 1', function () {
// ...
})->todo(assignee: 'paulredmond', issue: 13);
 
it('returns a successful response', function () {
$response = $this->get('/');
 
$response->assertStatus(200);
})->todo(
assignee:'paulredmond',
issue:11,
pr:1,
note:'Need to assert the response body.'
);
 
// Eric is a closer ☕️
test('drives always go in the fairway', function () {
// ...
})->done(assignee: 'ericlbarnes', issue: 13);

From the command line, you can filter tests by assignee or issue:

$ pest --issue=11
$ pest --assignee=paulredmond --pr=1
$ pest --assignee=ericlbarnes
$ pest --issue=13
$ pest --notes # returns tests with notes

Architecture Presets

Architecture presets are a way to quickly use the same architecture rules across multiple projects, and leverage popular presets like rules for Laravel, PHP, a strict PHP preset, or a relaxed preset. These will create more consistency in your code because they'll prevent you from doing things like leaving debug functions like phpinfo(), dd(), etc.

You can use these presets using the arch()->preset() method:

// Ensures PHP functions like die(), phpinfo(), etc. are not used
arch()->preset()->php();
 
// Ensures functions like eval(), md5(), etc. are not used.
arch()->preset()->security();
 
// Preset to validate things like resourceful controller methods,
// enum organization, controller files have a `Controller` suffix, etc.
arch()->preset()->laravel();
 
// Preset to ensure classes are final, strict typing, etc.
arch()->preset()->strict();
 
// Preset to ensure strict types are not used, no final, no private methods.
arch()->preset()->relaxed();

Presets speed up development because most rules you'd expect are already defined for you. Here's an example of the security preset failing because of the use of md5():

Here's an example of using the Strict preset, demonstrating a class that is not using the final keyword:

Mutation Testing

When mutation testing ships with Pest v3, it's going to blow your mind. Mark my words, when you run mutation tests on your codebase, this feature is going to make you cry, and then you won't be able to live without it.

Even if your test suite reports 100% coverage, mutation testing will help you find gaps in your tests. It does so by removing code from your implementation, swapping logic around, and poking holes in your code to try to make your tests fail.

Backwards Compatibility

Near the end of his talk, Nuno mentioned that Pest 2 users will be able to upgrade without any backward compatibility breaks. Users should be able to update the package to require v3 and update composer dependencies. This is huge because fixing compatibility breaks in your testing tool can be painful, especially if you have a lot of tests.

The future of Pest is bright with productive tools that level up your testing through mutations, make your application architecture more consistent, and help keep track of assignees and issues directly in your tests.

Which feature are you most excited about? Let us know on your favorite social media app!

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Filed in:
Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Tinkerwell

Enjoy coding and debugging in an editor designed for fast feedback and quick iterations. It's like a shell for your application – but with multi-line editing, code completion, and more.

Visit Tinkerwell
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $3200/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit

The latest

View all →
Clawdbot Rebrands to Moltbot After Trademark Request From Anthropic image

Clawdbot Rebrands to Moltbot After Trademark Request From Anthropic

Read article
Automate Laravel Herd Worktrees with This Claude Code Skill image

Automate Laravel Herd Worktrees with This Claude Code Skill

Read article
Laravel Boost v2.0 Released with Skills Support image

Laravel Boost v2.0 Released with Skills Support

Read article
Laravel Debugbar v4.0.0 is released image

Laravel Debugbar v4.0.0 is released

Read article
Radiance: Generate Deterministic Mesh Gradient Avatars in PHP image

Radiance: Generate Deterministic Mesh Gradient Avatars in PHP

Read article
Speeding Up Laravel News With Cloudflare image

Speeding Up Laravel News With Cloudflare

Read article