From c59e451ca90107fe4beb9916b2451911082f8834 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Tue, 21 Oct 2025 14:25:26 -0400 Subject: [PATCH] fix(@angular/build): direct check include file exists in unit-test discovery When discovering unit-test files, the `include` option values that are not dynamic patterns will now be checked directly if they exist on the file system. This avoids glob calls for specific files and helps avoid Windows pathing issues with glob syntax. --- .../build/src/builders/unit-test/test-discovery.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/angular/build/src/builders/unit-test/test-discovery.ts b/packages/angular/build/src/builders/unit-test/test-discovery.ts index a7022924c622..987b55e39a81 100644 --- a/packages/angular/build/src/builders/unit-test/test-discovery.ts +++ b/packages/angular/build/src/builders/unit-test/test-discovery.ts @@ -232,20 +232,20 @@ async function resolveStaticPattern( return { resolved: [], unresolved: [`${pattern}/**/*.@(${infixes}).@(ts|tsx)`] }; } - const fileExt = extname(pattern); - const baseName = basename(pattern, fileExt); + const fileExt = extname(fullPath); + const baseName = basename(fullPath, fileExt); for (const infix of TEST_FILE_INFIXES) { - const potentialSpec = join( - projectSourceRoot, - dirname(pattern), - `${baseName}${infix}${fileExt}`, - ); + const potentialSpec = join(dirname(fullPath), `${baseName}${infix}${fileExt}`); if (await exists(potentialSpec)) { return { resolved: [potentialSpec], unresolved: [] }; } } + if (await exists(fullPath)) { + return { resolved: [fullPath], unresolved: [] }; + } + return { resolved: [], unresolved: [pattern] }; }