A package that creates PEST tests specifically tailored for your filament resources.
MIT License
A package that creates PEST tests specifically tailored for your Filament components.
[!IMPORTANT] The project is currently on hold as both active maintainers are unable to dedicate time due to work commitments and other responsibilities. However, we encourage anyone in the community to contribute and help keep the project alive. Your efforts would make a big difference in maintaining its momentum.
This package is still in early development. Some features may not be available yet or may not work as expected. If you encounter any issues, please create an issue on this repository.
[!CAUTION] This package is not production-ready yet, use it at your own risk. ⚠️
You can install the package via composer:
composer require codewithdennis/filament-tests --dev
You can publish the config file with:
php artisan vendor:publish --tag="filament-tests-config"
This package requires Filament v3 or later to run.
This package generates PestPHP tests, make sure you have it installed in your project. You can install it by running the following command:
composer require pestphp/pest --dev --with-all-dependencies
Make sure you have the following plugins installed as well:
composer require pestphp/pest-plugin-livewire --dev
composer require pestphp/pest-plugin-laravel --dev
You can create a new test for a resource by running the following command:
The following name formats are supported:
blog
,Blog
,BlogResource
php artisan make:filament-test BlogResource
You can also pass a comma-separated list of resource names to create tests for multiple resources at once:
php artisan make:filament-test "BlogResource, PostResource"
If you don't specify a resource name, you will be prompted to choose one or more resources to create tests for interactively.
php artisan make:filament-test
Option | Description |
---|---|
--all -a
|
Create tests for all Filament resources |
--directory -d
|
The output directory for the test |
--except -e
|
Create tests for all Filament resources except the specified resources |
--force -f
|
Overwrite existing tests |
--only -o
|
Create tests for the specified resources |
Tests are generated on demand and are tailored to the component that you're generating tests for. For example, if the resource component doesn't have any sortable columns, then the tests for sorting won't be generated.
You can customize the stubs by publishing them to your project:
php artisan vendor:publish --tag="filament-tests-stubs"
💡 Please make sure to uncomment
Illuminate\Foundation\Testing\RefreshDatabase::class
intests/Pest.php
before running the tests.Additionally, make sure to have a
.env.testing
file with a valid database connection or uncomment theDB_CONNECTION
andDB_DATABASE
values in thephpunit.xml
file.
You can run your tests normally by running the following command:
vendor/bin/pest
You can choose to only run the tests for this package by running the following command:
vendor/bin/pest --group=filament-tests
You can also run all your tests except the ones for this package by running the following command:
vendor/bin/pest --exclude-group=filament-tests
Name | Includes |
---|---|
filters |
Runs the tests for the filters |
page |
Runs the tests for the pages |
render |
Runs the tests that check if the page renders correctly |
table |
Runs the tests for the table |
table-actions |
Runs the tests for table actions |
table-bulk-actions |
Runs the tests for table bulk actions |
You can add any of those above groups to either
--exclude-group
or--group
to include or exclude them from the test run. You can comma-separate multiple groups.
The MIT License (MIT). Please see License File for more information.