Skip to content

Commit c59e451

Browse files
committed
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.
1 parent 18bf8e7 commit c59e451

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/angular/build/src/builders/unit-test/test-discovery.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,20 +232,20 @@ async function resolveStaticPattern(
232232
return { resolved: [], unresolved: [`${pattern}/**/*.@(${infixes}).@(ts|tsx)`] };
233233
}
234234

235-
const fileExt = extname(pattern);
236-
const baseName = basename(pattern, fileExt);
235+
const fileExt = extname(fullPath);
236+
const baseName = basename(fullPath, fileExt);
237237

238238
for (const infix of TEST_FILE_INFIXES) {
239-
const potentialSpec = join(
240-
projectSourceRoot,
241-
dirname(pattern),
242-
`${baseName}${infix}${fileExt}`,
243-
);
239+
const potentialSpec = join(dirname(fullPath), `${baseName}${infix}${fileExt}`);
244240
if (await exists(potentialSpec)) {
245241
return { resolved: [potentialSpec], unresolved: [] };
246242
}
247243
}
248244

245+
if (await exists(fullPath)) {
246+
return { resolved: [fullPath], unresolved: [] };
247+
}
248+
249249
return { resolved: [], unresolved: [pattern] };
250250
}
251251

0 commit comments

Comments
 (0)