Laravel Cloud is here! Zero-config managed infrastructure for Laravel apps. Deploy now.

Everything We Know About Pest 4

Published on by

Everything We Know About Pest 4 image

Nuno Maduro was the second speaker at Laracon US 2025 on Tuesday, unveiling new features for the upcoming Pest v4.0. When we wrote about Nuno's Pest 3 talk at Laracon US in 2024, users had installed Pest over 18 million times. A year later, Pest has been installed around 39 million times!

If you thought Pest v2 and Pest v3 were huge, Pest v4 takes things to a whole new level! This release focuses on marrying the best of unit testing and browser testing.

Nuno introducing browser testing for Pest v4
Nuno introducing browser testing for Pest v4

You can easily start writing modern browser tests in Pest 4, powered by Playwright. Never has testing between your application backend and frontend ever been as cohesive.

  • End-to-end browser testing in Pest
  • Visual testing
  • Device testing
  • Code coverage with browser and unit tests
  • Tinker sesssions mid-test
  • Test sharding for parallel test runs in CI
  • And more...

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

Browser Testing in Pest

Browser testing in Pest unlocks the ability to run tests in your browser using modern tools like Playwright, but without having a separate test suite for unit and end-to-end tests. Combining browser and unit testing creates cohesion in your testing framework and unlocks new possibilities:

test('login', function () {
$user = User::factory()->create();
 
visit('/')
->click('Log in')
->type('email', $user->email)
->type('password', 'secret')
->press('Log in')
->assertSee('Dashboard');
});

Pest automatically waits after interacting with the page, clicking links, filling out and submitting forms, then asserting that the user visits the dashboard. Along with these powerful APIs, Pest allows you to debug browser tests using the ->debug() method and ->tinker():

test('login', function () {
$user = User::factory()->create();
 
visit('/')
->click('Log in')
->type('email', $user->email)
->type('password', 'secret')
->press('Log in')
->assertSee('Dashboard')
->tinker();
});

The above tinker() method will pause execution, and give you the state of the server and database in a REPL:

Tinker REPL while browser testing
Tinker REPL while browser testing

Visual Testing

Pest 4 includes visual testing methods that can detect when your page UI has changed by comparing the diff of a before and after screenshot. This unlocks the ability to compare your UI before and after a change and ensure no regressions have happened:

Visual debug image indicates where a UI has changed
Visual debug image indicates where a UI has changed
A slider to compare before and after UI changes side-by-side
A slider to compare before and after UI changes side-by-side
Visual comparison after changing CSS
Visual comparison after changing CSS

Smoke Testing

Smoke testing in Pest 4 is a powerful way to ensure that requests in your application are successful and that no JavaScript errors have occurred. You can use smoke testing to quickly determine that pages in your application are free from JavaScript errors and console logs:

test('login', function () {
$user = User::factory()->create();
 
visit(['/', '/about'])
->assertNoJavaScriptErrors()
->assertNoConsoleLogs();
 
// Or simply check for no errors/logs with:
visit(['/', '/about'])
->assertNoSmoke();
});

Device Testing and Light/Dark Mode

Pest 4 has new features for device testing that make it easy to specify the type of device to run a test with. Here are a few examples from Nuno's Laracon US presentation:

visit('/')->on()->mobile();
visit('/')->on()->iPhone15();
visit('/')->inDarkMode();
visit('/')->inLightMode();
// ...

Parallel Testing

Pest 4 supports parallel testing in the browser via Playwrights parallel capabilities. This makes the test suite run much faster than previous browser-based test suites like Dusk. Further, on GitHub actions you can leverage parallel testing using the --shard flag to split testing into separate jobs that run in parallel:

strategy:
matrix:
shard: [1, 2, 3, 4, 5]
 
name: Tests (Shard ${{ matrix.shard }}/5)
 
steps:
- name: Run tests
run: pest --parallel --shard ${{ matrix.shard }}/5

Release Date

Pest 4 is expected to release on August 21, 2025, this year at Laravel Live Denmark 2025. 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
Laravel Code Review

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

Visit Laravel Code Review
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 →
Laravel Fuse: A Circuit Breaker Package for Queue Jobs image

Laravel Fuse: A Circuit Breaker Package for Queue Jobs

Read article
Generate Complete Application Modules with a Single Command using Laravel TurboMaker image

Generate Complete Application Modules with a Single Command using Laravel TurboMaker

Read article
`hasSole()` Collection Method in Laravel 12.49.0 image

`hasSole()` Collection Method in Laravel 12.49.0

Read article
Install Laravel Package Guidelines and Skills in Boost image

Install Laravel Package Guidelines and Skills in Boost

Read article
Bagisto Visual: Theme Framework with Visual Editor for Laravel E-commerce image

Bagisto Visual: Theme Framework with Visual Editor for Laravel E-commerce

Read article
Clawdbot Rebrands to Moltbot After Trademark Request From Anthropic image

Clawdbot Rebrands to Moltbot After Trademark Request From Anthropic

Read article