How to Install Laravel Pest Testing Framework
You can install the Laravel Pest testing framework either on an existing or new Laravel project. If you are new to Laravel, read how to install Laravel 8 on Ubuntu. However, either way, make sure at least that you are using PHP 7.3 or a newer version. If everything looks ok, open a terminal window and go to your Laravel 8 project directory.
cd /path/to/laravel-project
Then, install the Laravel Pest testing framework plugin by running the following command. We use the --dev
flag to make it installed as a development package.
composer require pestphp/pest-plugin-laravel --dev
Once the installation is completed, run the following command. It will create a file called Pest.php
in Laravel tests
directory.
php artisan pest:install
After that, you can create Pest tests with the following command.
php artisan pest:test HomeTest
Mainly, there are two types of tests in Laravel called “Feature tests” and “Unit tests”. By default, the pest:test
command creates feature tests. But instead, if you need to create a unit test, you can mention the --unit
to the pest:test
command like below.
php artisan pest:test TransactionTest --unit
Additionally, you can create
Laravel Dusk tests as well. Mention the --dusk
flag when you create the test with pest:test
like below.
php artisan pest:test CartTest --dusk
However, if you are planning to run Laravel Dusk tests, you need to install it.