Pest
Last modified on Thu 27 Jan 2022
Pest is a testing framework that mimics the syntax of Jest.
It's a wrapper around the PHPUnit test suite with a more fluent syntax.
Installing Pest is simple:
composer require pestphp/pest --dev --with-all-dependencies
Then create a tests
folder and run the init command:
./vendor/bin/pest --init
After that you can run Pest with:
./vendor/bin/pest
We are using Pest for unit testing purposes on the Eightshift libs.
Writing tests is really simple. You can use either it
or test
function
<?php
it('makes sure test works', function() {
$this->assertTrue(true);
});
This is a trivial example that doesn't actually test anything other than that the test suite is working.
Currently it's only possible to use Pest as unit test suite, for integration testing you're still better off with wp-browser.