Automatically format your Pest PHP tests.

Installs: 343 943

Dependents: 1

Suggesters: 0

Security: 0

Stars: 6

Watchers: 14

Forks: 1

Open Issues: 0


v0.2.2 2024-02-08 20:17 UTC

This package is auto-updated.

Last update: 2024-06-08 21:08:23 UTC


Enforce consistent styling for your Pest PHP tests!


There are lots of important decisions to worry about as a developer. You know what you shouldn't be worrying about? The order of your tests! But you still want your tests to look nice, right?

That's why we created Pretty Pest. This code style plugin ensures that your Pest tests are automatically formatted correctly so that you don't have to spend time doing so manually.


You can install the package via composer.

composer require worksome/pretty-pest --dev


You can enable Pretty Pest in PHPCBF by adding the PrettyPest rule to your phpcs.xml file.

<rule ref="PrettyPest"/>

Pretty Pest has 2 sniffs for PHPCBF:

  • EnsureTestFunctionsAreOrdered
  • NewLineAfterTestFunctions


This sniff will ensure that your pest functions are ordered correctly in the test file. By default, we use the following order:

    // The array syntax indicates that `test` and `it` are to be treated as the same function.
    ['test', 'it'],

Any functions that are out of order will be moved in the file. Of course, you can always override this order to your preference in the phpcs.xml file.

<rule ref="PrettyPest.Formatting.EnsureFunctionsAreOrdered">
        <property name="order" type="array">
            <element value="uses"/>
            <element value="beforeAll"/>
            <element value="beforeEach"/>
            <element value="test"/>
            <element value="it"/>
            <element value="dataset"/>
            <element value="afterEach"/>
            <element value="afterAll"/>


This sniff will replace all whitespace after a Pest function with a single new line to ensure that spacing in your test files is consistent.


Please see CHANGELOG for more information on what has changed recently.



The MIT License (MIT). Please see License File for more information.