News

Everything We Know About Pest 4

Published
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

Sponsored

acquaintsoft logo
Acquaint Softtech

Hire Laravel developers with AI expertise at $20/hr. Get started in 48 hours.

Visit Acquaint Softtech

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article