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

Medior Laravel Backend Developer (The Netherlands/Dutch only)
Nijmegen, The Netherlands
BigSpark B.V.
Laravel Developer
Remote
Enjin
Senior Laravel Backend Engineer
Remote, USA Only
Kittyhawk.io, Inc.
Full Stack Developer
Rijssen
CODE14
Senior PHP Developer
Remote
ProjectMark

Newsletter

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