Skip to content
spatie avatar

Pest Testing

Pest 4 test-writing guide covering unit, feature, and browser tests with assertions, datasets, and mocking.

CCM score
67 of 100
skills.sh installs
759
GitHub stars
647
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers writing and running Pest tests: unit, feature, browser, smoke, visual regression, and architecture tests
  • Includes assertion substitutions (assertSuccessful(), assertNotFound(), assertForbidden()) in place of assertStatus() calls
  • Enforces that tests are not removed without approval and that assertNoJavascriptErrors() is used in browser tests
  • Designed for Laravel projects using Pest 4 for browser, smoke, and architecture testing

Install

$ npx -y skills add spatie/freek.dev --skill pest-testing -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Pest Testing 4

When to Apply

Activate this skill when:

  • Creating new tests (unit, feature, or browser)
  • Modifying existing tests
  • Debugging test failures
  • Working with browser testing or smoke testing
  • Writing architecture tests or visual regression tests

Documentation

Use search-docs for detailed Pest 4 patterns and documentation.

Basic Usage

Creating Tests

All tests must be written using Pest. Use php artisan make:test --pest {name}.

Test Organization

  • Unit/Feature tests: tests/Feature and tests/Unit directories.
  • Browser tests: tests/Browser/ directory.
  • Do NOT remove tests without approval - these are core application code.

Basic Test Structure

it('is true', function () { expect(true)->toBeTrue(); });

Running Tests

  • Run minimal tests with filter before finalizing: php artisan test --compact --filter=testName.
  • Run all tests: php artisan test --compact.
  • Run file: php artisan test --compact tests/Feature/ExampleTest.php.

Assertions

Use specific assertions (assertSuccessful(), assertNotFound()) instead of assertStatus():

Details

Repository
github.com/spatie/freek.dev
Categories
Testing & QA, PHP & Laravel
First seen
Jun 3, 2026

Questions

What is the pest-testing skill for?

The pest-testing skill helps an agent write and debug tests with the Pest 4 PHP framework. It covers unit and feature tests, assertions, datasets, mocking, Livewire components, and browser testing.

How do I install the pest-testing skill?

Run npx -y skills add spatie/freek.dev --skill pest-testing -y in a project to install it. Once installed, the agent can create Pest tests with php artisan make:test --pest and run them with php artisan test.

Which skills sit alongside pest-testing in the Testing & QA category?

The pest-testing skill is listed in the Testing & QA category, next to tdd, test-driven-development, webapp-testing, and break-ui. Its focus is Pest 4 specifically, with browser testing, smoke testing, and architecture tests.

Does pest-testing support browser and smoke testing?

Yes, the skill covers browser tests in tests/Browser that run in real browsers, along with smoke tests that check several pages for JavaScript errors. It also describes visual regression testing and test sharding for parallel CI runs.

What assertions does pest-testing recommend?

The skill recommends specific assertions such as assertSuccessful(), assertNotFound(), and assertForbidden() instead of assertStatus() with a raw code. It also reminds the agent to import use function Pest\Laravel\mock; before mocking.

More from spatie/freek.dev

All 2

Similar to Pest Testing

More Testing & QA