Skip to content

Commit 85db436

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 85db436

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,15 +232,15 @@ 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+
if (await exists(fullPath)) {
236+
return { resolved: [fullPath], unresolved: [] };
237+
}
238+
239+
const fileExt = extname(fullPath);
240+
const baseName = basename(fullPath, fileExt);
237241

238242
for (const infix of TEST_FILE_INFIXES) {
239-
const potentialSpec = join(
240-
projectSourceRoot,
241-
dirname(pattern),
242-
`${baseName}${infix}${fileExt}`,
243-
);
243+
const potentialSpec = join(dirname(fullPath), `${baseName}${infix}${fileExt}`);
244244
if (await exists(potentialSpec)) {
245245
return { resolved: [potentialSpec], unresolved: [] };
246246
}

0 commit comments

Comments
 (0)