Back to Course |
Testing in Laravel 11 For Beginners

Pest 3: Team Management

With Pest you can assign tests to a user, issue, or pull request. To use this feature, you must first specify a project.

tests/Pest.php:

pest()->extend(Tests\TestCase::class)
->use(Illuminate\Foundation\Testing\RefreshDatabase::class)
->in('Feature');
 
pest()->project()->github('LaravelDaily/Laravel-Testing-Course');

You can use gitlab, bitbucket, jira, or custom methods instead of GitHub.

For example, you can set a todo for a test and assign a user.

test('product shows when published at correct time', function () {
// ...
})->todo(assignee: 'PovilasKorop');

You can provide multiple assignees by providing them in an array.

Now, when running the tests, you can filter them by assignee.

php artisan test --todos --assignee=PovilasKorop

You can assign an issue or a pull request.

test('product shows when published at correct time', function () {
//
})->todo(issue: 1, pr: 123);

When you are working on a test, you can mark it as a work in progress by using the wip() method. This way, the test won't have a todo status and will run as a regular test.

test('product shows when published at correct time', function () {
//
})->wip(assignee: 'PovilasKorop', issue: 1, pr: 123);

Once you are done working, you can mark a test as done using the done() method.

test('product shows when published at correct time', function () {
//
})->wip(done: 'PovilasKorop', issue: 1, pr: 123);

This is the basics of using team management within Pest. For more, check the official documentation.