// docs / plugins

Plugins

In this section, we will discuss the official and community-developed plugins that we endorse. Plugins primarily offer namespaced functions, console commands, custom expectations, and additional command-line options that augment the default Pest experience.

If you are a plugin developer, please consult our documentation on creating plugins for more information on building your own Pest plugins.

The following plugins are maintained by the Pest team:

Faker

Source code: github.com/pestphp/pest-plugin-faker

To get started with Pest's Faker plugin, require the plugin via Composer:

1composer require pestphp/pest-plugin-faker --dev

Once the plugin is installed, you may use the namespaced fake function to generate fake data for your tests:

1use function Pest\Faker\fake;
2 
3it('generates a name', function () {
4 $name = fake()->name; // random name...
5 
6 //
7});

You may also designate the "locale" that the fake() function should use by passing it to the function:

1use function Pest\Faker\fake;
2 
3it('generates a portuguese name', function () {
4 $name = fake('pt_PT')->name; // Nuno Maduro
5 
6 //
7});

To learn more about Faker, including comprehensive details about the API it provides, please consult its official documentation.

Laravel

Source code: github.com/pestphp/pest-plugin-laravel

To get started with Pest's Laravel plugin, require the plugin via Composer:

1composer require pestphp/pest-plugin-laravel --dev

This plugin adds additional Artisan commands and functions to the default Pest installation. For example, to generate a new test in the tests/Feature directory, you may now use the pest:test Artisan command:

1php artisan pest:test UsersTest

You may provide the --unit option when creating a test to place the test in the tests/Unit directory:

1php artisan pest:test UsersTest --unit

Executing the pest:dataset Artisan command will create a fresh dataset in the tests/Datasets directory:

1php artisan pest:dataset Emails

As you may know, Laravel provides a variety of assertions you may take advantage of in your feature tests. When using Pest's Laravel plugin, you may access all of those assertions as you typically would:

1it('has a welcome page', function () {
2 $this->get('/')->assertStatus(200);
3});

In addition, this plugin allows you to bypass the $this variable while using namespaced functions such as actingAs, get, post, and delete:

1use function Pest\Laravel\{get};
2 
3it('has a welcome page', function () {
4 get('/')->assertStatus(200);
5 // same as $this->get('/')...
6});

To illustrate this convenient feature with another example, let's write a test acting as an authenticated user accessing the restricted dashboard page:

1use App\Models\User;
2use function Pest\Laravel\{actingAs};
3 
4test('authenticated user can access the dashboard', function () {
5 $user = User::factory()->create();
6 
7 actingAs($user)->get('/dashboard')
8 ->assertStatus(200);
9});

As you would expect, all of the assertions that were previously accessible via $this-> are available as namespaced functions:

1use function Pest\Laravel\{actingAs, get, post, delete, ...};

You may find the full testing documentation on the Laravel website: laravel.com/docs/12.x/testing.

Livewire

Source code: github.com/pestphp/pest-plugin-livewire

To get started with Pest's Livewire plugin, require the plugin via Composer:

1composer require pestphp/pest-plugin-livewire --dev

Once the plugin is installed, you may use the livewire namespaced function to access your Livewire components:

1use function Pest\Livewire\livewire;
2 
3it('can be incremented', function () {
4 livewire(Counter::class)
5 ->call('increment')
6 ->assertSee(1);
7});
8 
9it('can be decremented', function () {
10 livewire(Counter::class)
11 ->call('decrement')
12 ->assertSee(-1);
13});

In this section, we have seen how plugins can enhance your Pest experience. Next, let's see how you may manage your team's tasks and responsibilities using Pest: Team Management