PestPHP Released as Open-Source

PestPHP Released as Open-Source

Console legend Nuno Maduro has open-sourced Pest, an elegant PHP testing framework that focuses on simplicity.

Here’s a quick example of what you can expect, which will be familiar to use if you’ve used other testing tools like Mocha or Jest:

test('asserts true is true', function () {
    assertTrue(true);
});

// or
it('asserts true is true', function () {
    assertTrue(true);
});

Under the hood, Pest tests are bound to a test-case class (PHPUnit’s TestCase by default), which means your closures run in the context of the configured test case:

it('has home', function () {
    $this->assertTrue(true);

    // \PHPUnit\Framework\TestCase
    echo get_class($this); 
});

Be sure to check out the documentation on how can customize the underlying test case via the uses() function that Pest provides.

Be sure to read the Laravel Guide to learn how to create tests with Pest in a Laravel application. Here’s a sneak peek at using a higher-order test with Laravel:

use Tests\Feature;
use Illuminate\Foundation\Testing\DatabaseMigrations;

uses(TestCase::class, DatabaseMigrations::class);

it('has home page')
    ->get('/')
    ->see('Laravel.io')
    ->see('The Laravel Community Portal');

Learn More

Check out PestPHP documentation to start using Pest, and view the source code on GitHub at pestphp/pest. . Pest also has guides for Symfony and PHPUnit. Finally, consider sponsoring Nuno for his excellent work on Pest, Laravel Zero, collision, and Larastan!

Filed in: News
Laravel News Partners

Laravel Jobs

Senior Full Stack Engineer - Laravel
Remote
Givebutter
Laravel partner seeks Lead Developer
Remote
Kirschbaum Development Group
Senior Programmer **Immediate Opening** (send resume to daniel@sbgcorp.com)
Remote
SBG Corp
Web Developer - Laravel
Grand Forks, North Dakota
Center for Rural Health
Senior Full-Stack Laravel Developer
Berlin, Germany
felmo.de

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.