Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsMay 19, 2026·2 min de lecture

Pest — Elegant PHP Testing Framework

Pest is a testing framework for PHP that focuses on simplicity and developer experience, offering an expressive syntax built on top of PHPUnit.

Prêt pour agents

Cet actif peut être lu et installé directement par les agents

TokRepo expose une commande CLI universelle, un contrat d'installation, le metadata JSON, un plan selon l'adaptateur et le contenu raw pour aider les agents à juger l'adaptation, le risque et les prochaines actions.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Pest Overview
Commande CLI universelle
npx tokrepo install d1ced1c9-53c0-11f1-9bc6-00163e2b0d79

Introduction

Pest brings a clean, minimal syntax to PHP testing inspired by Jest and RSpec. It wraps PHPUnit so existing test suites can adopt Pest incrementally without rewriting anything.

What Pest Does

  • Provides a fluent closure-based test syntax for PHP
  • Runs on top of PHPUnit with full compatibility
  • Offers built-in architecture testing for enforcing code rules
  • Supports parallel test execution and test profiling
  • Includes snapshot testing and type coverage analysis

Architecture Overview

Pest is a thin layer over PHPUnit that transforms its closure-based test() and it() calls into standard PHPUnit test cases at runtime. Test files are plain PHP scripts without class boilerplate. Pest discovers and loads them through its own test suite loader, then delegates execution to the PHPUnit engine.

Self-Hosting & Configuration

  • Install via Composer as a dev dependency
  • Initialize with ./vendor/bin/pest --init to scaffold config
  • Configure in pest.php or fall back to phpunit.xml
  • Use --parallel flag to run tests across multiple processes
  • Integrate with CI by running ./vendor/bin/pest --ci

Key Features

  • Minimal closure-based test syntax with zero class boilerplate
  • Architecture testing to enforce dependency and namespace rules
  • Built-in code coverage and type coverage reporting
  • Snapshot testing for complex output assertions
  • Parallel execution for faster test suite runs

Comparison with Similar Tools

  • PHPUnit — class-based tests with more ceremony; Pest wraps PHPUnit with a simpler API
  • Codeception — full-stack BDD testing; Pest focuses on unit and feature tests with less setup
  • PHPSpec — spec-driven design tool; Pest is a general-purpose test runner
  • Jest — JavaScript testing; Pest brings a similar developer experience to PHP
  • Behat — behavior-driven with Gherkin syntax; Pest uses plain PHP closures

FAQ

Q: Can I use Pest alongside existing PHPUnit tests? A: Yes. Pest is fully compatible with PHPUnit. Both styles can coexist in the same project.

Q: Does Pest support Laravel? A: Yes. The pestphp/pest-plugin-laravel package adds Laravel-specific helpers and assertions.

Q: Is Pest slower than PHPUnit? A: No. Pest adds negligible overhead since it delegates execution to PHPUnit internally.

Q: What PHP versions does Pest support? A: Pest v3 requires PHP 8.2 or higher.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires