Allow help and version before the test suite is initialized (#2051)

Co-authored-by: haranishi <223786623+haranishi@users.noreply.github.com>
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
This commit is contained in:
Ikki Nishihara
2026-11-20 18:50:17 +09:00
committed by GitHub
parent f80b3a89a0
commit 67d3733eb2
4 changed files with 31 additions and 9 deletions
+20
View File
@@ -1,6 +1,7 @@
<?php
use Symfony\Component\Process\Process;
use Tests\Fixtures\Tia\Project;
test('visual snapshot of help command output', function (): void {
$output = function (): ?string {
@@ -13,3 +14,22 @@ test('visual snapshot of help command output', function (): void {
expect($output())->toMatchSnapshot();
})->skipOnWindows()->skip(! getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE'));
test('prints information when the tests directory is missing', function (string $option, string $expected): void {
$project = Project::withoutGit();
try {
rename($project->path('tests'), $project->path('fixtures'));
unlink($project->path('phpunit.xml'));
$result = $project->pest($option);
expect($result->exitCode)->toBe(0, $result->describe())
->and($result->output)->toContain($expected);
} finally {
Project::destroyAll();
}
})->with([
'help' => ['--help', '--init'],
'version' => ['--version', 'Pest Testing Framework'],
]);