fix(tia): let JS modules no Inertia page imports fall back to the watch patterns (#1936)

This commit is contained in:
cyppe
2026-10-31 15:46:43 +01:00
committed by GitHub
parent 52ee93b3c4
commit 85d24777b5
3 changed files with 29 additions and 2 deletions
-2
View File
@@ -355,8 +355,6 @@ final class Graph
$pages = $freshMap[$rel] ?? [];
if ($pages === []) {
$sharedFilesResolved[$rel] = true;
continue;
}
+21
View File
@@ -2,6 +2,7 @@
declare(strict_types=1);
use Pest\Plugins\Tia\JsModuleGraph;
use Tests\Fixtures\Tia\Project;
afterEach(function (): void {
@@ -216,3 +217,23 @@ test('a changed frontend runtime file selects every Inertia test', function ():
expect($result->affected())->toBe(2, $result->describe())
->and($result->replayed())->toBe(4, $result->describe());
})->skipOnWindows();
test('a changed JS module that no Inertia page imports falls back to the watch patterns', function (): void {
$project = Project::make('master', 'js-watch');
$project->write('vite.config.js', "export default {}\n");
$project->write('resources/js/widget.js', "export const widget = 1\n");
$project->git()->commit('add a Vite app without Inertia pages');
$project->seed('master');
$fingerprint = new ReflectionMethod(JsModuleGraph::class, 'fingerprint')->invoke(null, $project->path());
file_put_contents($project->graphDir().DIRECTORY_SEPARATOR.'js-module-graph.cache.json', json_encode(['fingerprint' => $fingerprint, 'graph' => []]));
$project->write('resources/js/widget.js', "export const widget = 2\n");
$project->snapshot();
$result = $project->pest('--tia');
expect($result->affected())->toBe(6, $result->describe())
->and($result->replayed())->toBe(0, $result->describe());
})->skipOnWindows();
@@ -0,0 +1,8 @@
<?php
declare(strict_types=1);
require_once __DIR__.'/../app/Calculator.php';
require_once __DIR__.'/../app/Greeter.php';
pest()->tia()->watch(['resources/js/**' => 'tests']);