mirror of
https://github.com/pestphp/pest.git
synced 2026-12-04 15:05:09 +01:00
28c9dc277d
* feat(tia): make default watch fallbacks configurable * test(tia): cover driverless fallback and update suite snapshots * fix: align help types and coverage guards with PHPStan --------- Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
66 lines
2.7 KiB
PHP
66 lines
2.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Tests\Fixtures\Tia\Project;
|
|
|
|
afterEach(function (): void {
|
|
Project::destroyAll();
|
|
});
|
|
|
|
test('excludes a default fallback in sequential and parallel runs', function (array $arguments): void {
|
|
$project = Project::make('master');
|
|
$project->write('tests/Pest.php', file_get_contents($project->path('tests/Pest.php')).
|
|
"\npest()->tia()->withoutDefaultWatchPatterns(['.env.testing']);\n");
|
|
$project->seed('master');
|
|
$project->write('.env.testing', 'APP_ENV=testing');
|
|
|
|
$result = $project->pest('--tia', '--filtered', ...$arguments);
|
|
|
|
expect($result->exitCode)->toBe(0, $result->describe())
|
|
->and($result->output)->toContain('No affected tests found');
|
|
})->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows();
|
|
|
|
test('retains custom mappings and PHP edges in sequential and parallel runs', function (array $arguments): void {
|
|
$project = Project::make('master');
|
|
$project->write('tests/Pest.php', file_get_contents($project->path('tests/Pest.php')).
|
|
"\npest()->tia()->withoutDefaultWatchPatterns()->watch(['.env.testing' => 'tests/Unit/GreeterTest.php']);\n");
|
|
$project->seed('master');
|
|
$project->write('.env.testing', 'APP_ENV=testing');
|
|
|
|
$result = $project->pest('--tia', '--filtered', ...$arguments);
|
|
|
|
expect($result->exitCode)->toBe(0, $result->describe())
|
|
->and($result->affected())->toBe(2, $result->describe());
|
|
|
|
$project->write('app/Calculator.php', str_replace(
|
|
'return $a + $b;',
|
|
'return ($a + $b);',
|
|
file_get_contents($project->path('app/Calculator.php')),
|
|
));
|
|
|
|
$result = $project->pest('--tia', '--filtered', ...$arguments);
|
|
|
|
expect($result->exitCode)->toBe(0, $result->describe());
|
|
|
|
if (str_contains($result->output, 'no coverage driver is available')) {
|
|
expect($result->output)->toContain('Running the full suite to avoid using a stale dependency graph.')
|
|
->and($result->tally())->toContain(Project::TOTAL_TESTS.' passed');
|
|
|
|
return;
|
|
}
|
|
|
|
expect($result->affected())->toBe(4, $result->describe());
|
|
})->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows();
|
|
|
|
test('still runs every test without a baseline when defaults are disabled', function (array $arguments): void {
|
|
$project = Project::make('master');
|
|
$project->write('tests/Pest.php', file_get_contents($project->path('tests/Pest.php')).
|
|
"\npest()->tia()->withoutDefaultWatchPatterns();\n");
|
|
|
|
$result = $project->pest('--tia', '--filtered', ...$arguments);
|
|
|
|
expect($result->exitCode)->toBe(0, $result->describe())
|
|
->and($result->tally())->toContain(Project::TOTAL_TESTS.' passed');
|
|
})->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows();
|