Grouping Tests
You may assign test folders to various groups using Pest's group() method. Assigning a group to a set of relatively slow tests can be helpful, as it allows you to run them separately from the rest of your test suite. Typically, you should assign a set of tests to a group within your Pest.php configuration file.
For instance, consider a scenario where we assign the tests located in the tests/Feature folder to a group named "feature":
1pest()->extend(TestCase::class)2 ->group('feature')3 ->in('Feature');
As mentioned in the Filtering Tests documentation, you may use the --group option to run the tests belonging to a specific group:
1./vendor/bin/pest --group=feature
You may also assign a particular test to a group by chaining the group() method onto the test function:
1it('has home', function () {2 //3})->group('feature');
Of course, you may also assign a test to multiple groups:
1it('has home', function () {2 //3})->group('feature', 'browser');
If you wish to assign a group to a describe block, you may do so by chaining the group() method onto the describe function:
1describe('home', function () {2 test('main page', function () {3 //4 });5})->group('feature');
Sometimes you may wish to assign a whole file to a group. To accomplish this, you may use the pest()->group() method within the file:
1pest()->group('feature');2 3it('has home', function () {4 //5});
When setting up a test suite, you may need to share common hooks between different folders and groups. In such cases, Global Hooks can prove helpful: Global Hooks