Enforce consistent styling for your Pest PHP tests

Related tags

Testing pretty-pest
Overview

Pretty Pest

Enforce consistent styling for your Pest PHP tests!

pest

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.

Installation

You can install the package via composer.

composer require worksome/pretty-pest --dev

PHPCBF

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

EnsureTestFunctionsAreOrdered

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

[
    'uses',
    'beforeAll',
    'beforeEach',
    'afterEach',
    'afterAll',
    // The array syntax indicates that `test` and `it` are to be treated as the same function.
    ['test', 'it'],
    'dataset',
]

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">
    <properties>
        <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"/>
        property>
    properties>
rule>

NewLineAfterTestFunctions

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.

Changelog

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

Credits

License

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

You might also like...
Mock HTTP requests on the server side in your PHP unit tests

HTTP Mock for PHP Mock HTTP requests on the server side in your PHP unit tests. HTTP Mock for PHP mocks the server side of an HTTP request to allow in

TestDummy makes the process of preparing factories (dummy data) for your integration tests as easy as possible

TestDummy TestDummy makes the process of preparing factories (dummy data) for your integration tests as easy as possible. As easy as... Build a Post m

A PHP library for mocking date and time in tests

ClockMock Slope s.r.l. ClockMock provides a way for mocking the current timestamp used by PHP for \DateTime(Immutable) objects and date/time related f

Extension to use built-in PHP server on Behat tests

Extension to use built-in PHP server on Behat tests Instalation composer require libresign/behat-builtin-extension Configuration Add the extension to

PHP Test Generator - A CLI tool which generates unit tests

This project make usages of PHPStan and PHPParser to generate test cases for a given PHP File.

vfsStream is a stream wrapper for a virtual file system that may be helpful in unit tests to mock the real file system. It can be used with any unit test framework, like PHPUnit or SimpleTest.

vfsStream vfsStream is a stream wrapper for a virtual file system that may be helpful in unit tests to mock the real file system. It can be used with

Some shorthand functions for skipping and focusing tests.

Pest Plugin: Shorthands This repository contains the Pest Plugin Shorthands. If you want to start testing your application with Pest, visit the main P

Magic Test allows you to write browser tests by simply clicking around on the application being tested, all without the slowness of constantly restarting the testing environment.

Magic Test for Laravel Magic Test allows you to write browser tests by simply clicking around on the application being tested, all without the slownes

To run time/IO related unit tests (e.g., sleep function calls, database queries, API calls, etc) faster using Swoole.

To run time/IO related unit tests (e.g., sleep function calls, database queries, API calls, etc) faster using Swoole.

Comments
Releases(v0.2.1)
  • v0.2.1(Apr 20, 2022)

    What's Changed

    • feat: add Git Attributes by @owenvoke in https://github.com/worksome/pretty-pest/pull/2

    New Contributors

    • @owenvoke made their first contribution in https://github.com/worksome/pretty-pest/pull/2

    Full Changelog: https://github.com/worksome/pretty-pest/compare/v0.2.0...v0.2.1

    Source code(tar.gz)
    Source code(zip)
Owner
Worksome
Building a future platform for flexible employment.
Worksome
Prevent none-test output in your Pest tests.

Pest Plugin Silence Often, when writing tests, we echo and dump test code to debug and check everything is working correctly. It can be easy to forget

Worksome 5 Feb 23, 2022
This plugin adds basic HTTP requests functionality to Pest tests, using minicli/curly

Curly Pest Plugin This plugin adds basic HTTP requests functionality to Pest tests, using minicli/curly. Installation composer require minicli/pest-pl

minicli 16 Mar 24, 2022
Integrates Pest with PHP-VCR using plugins.

Pest plugin for PHP-VCR Integrates Pest with PHP-VCR using plugins. Installation You can install the package via composer: composer require phpjuice/p

PHPJuice 4 Sep 1, 2021
Pest is an elegant PHP Testing Framework with a focus on simplicity

Pest is an elegant PHP Testing Framework with a focus on simplicity. It was carefully crafted to bring the joy of testing to PHP. Explore the docs: pe

PEST 5.9k Dec 27, 2022
⛽ Pest plugin to test Laravel applications powered by Octane.

⛽ Laravel Octane (Pest Plugin) Pest plugin to test Laravel applications powered by Octane. Install Via Composer composer require --dev cerbero/pest-pl

Andrea Marco Sartori 21 Apr 5, 2022
Add mocking capabilities to Pest or PHPUnit

This repository contains the Pest Plugin Mock. The Mocking API can be used in regular PHPUnit projects. For that, you just have to run the following c

PEST 16 Dec 3, 2022
A Pest plugin to control the flow of time

This Pest plugin offers a function testTime that allows you to freeze and manipulate the current time in your tests.

Spatie 34 Nov 16, 2022
The Pest Parallel Plugin

This repository contains the Pest Plugin Parallel. If you want to start testing your application with Pest, visit the main Pest Repository. Explore th

PEST 28 Dec 5, 2022
PHPUnit to Pest Converter

PestConverter PestConverter is a PHP library for converting PHPUnit tests to Pest tests. Before use Before using this converter, make sure your files

null 10 Nov 21, 2022
Given When Then (GWT) Plugin for Pest

Given When Then (GWT) Plugin for Pest A simple API allows you to structure your tests focused on the behaviour. Given-When-Then separation makes the t

Milroy Fraser 85 Dec 22, 2022