andaniel05/undescribed-tests

Allow the creation of tests with Pest omitting the description
4
Install
composer require andaniel05/undescribed-tests
Latest Version:v1.0.0
License:MIT
Last Updated:May 10, 2026
Links: GitHub  ·  Packagist
Maintainer: andaniel05

Undescribed Tests

A wrapper for PestPHP's test() function that allows creating tests without providing a description. When omitted, the description is automatically generated using the file name and line number where the closure is defined.

Installation

composer require andaniel05/undescribed-tests

Usage

Omitting description

When passing only a closure as argument, the description is automatically generated:

<?php

use Andaniel05\UndescribedTests\Facade;

Facade::test(function () {
    expect(true)->toBe(true);
});

Expected output:

✓ tests/Unit/FacadeTest.php:5

Using empty string

You can also pass an empty string explicitly:

Facade::test('', function () {
    expect(true)->toBe(true);
});

Explicit description

If you prefer, you can still use a manual description like in regular Pest:

Facade::test('my described test', function () {
    expect(true)->toBe(true);
});

Recommended approach: create a custom wrapper (ideal)

Instead of calling Facade::test() directly throughout your tests, create a wrapper function in your tests/Pest.php:

function _test(string|Closure|null $description = null, ?Closure $closure = null): HigherOrderTapProxy|TestCall
{
    return Facade::test($description, $closure);
}

Then use it in your test files:

_test(function () {
    expect(true)->toBe(true);
});

The package andaniel05/test-function contains an installable _test wrapper.

Groups

When the description is omitted, the test is automatically assigned to the undescribed group (or any other you specify). This allows easy filtering of tests without explicit description:

Facade::test(function () {
    expect(true)->toBe(true);
}); // Assigned to 'undescribed' group

Facade::test('', function () {
    expect(true)->toBe(true);
}, 'my-group'); // Assigned to 'my-group' group

When an explicit description is provided, no group is automatically assigned.

API

Facade::test()

public static function test(
    string|Closure|null $description = null,
    ?Closure $closure = null,
    ?string $undescribedGroupName = 'undescribed',
): HigherOrderTapProxy|TestCall
Parameter Type Description
description string|Closure|null Test description or closure (if description is omitted)
closure Closure|null Closure with assertions
undescribedGroupName string|null Group for tests without description (default: undescribed)

How it works

Internally, the Facade class uses ReflectionFunction to inspect the closure and extract:

  • The file path where it is defined
  • The line number where the closure starts

With this information, it builds an automatic description with the format: relative/path/file.php:line_number

Running tests

./vendor/bin/pest

Filter by group

./vendor/bin/pest --group=undescribed

Related Packages

erirk/paypalpayment

laravel-paypalpayment is simple package help you process direct credit card paym...

0
gabrieloliverio/laravel5-generators

Database metadata-based generators for Laravel 5

1
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

610,259,779 9,704
laravel/framework

The Laravel Framework.

551,557,428 34,802
laravel/tinker

Powerful REPL for the Laravel framework.

462,518,693 7,436