andaniel05/undescribed-tests 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

andaniel05/undescribed-tests

最新稳定版本:v1.0.0

Composer 安装命令:

composer require andaniel05/undescribed-tests

包简介

Allow the creation of tests with Pest omitting the description

README 文档

README

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

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 9
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固