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 89d38dbbe787..47bfed884ad3 100644 --- a/packages/angular/build/src/builders/unit-test/test-discovery.ts +++ b/packages/angular/build/src/builders/unit-test/test-discovery.ts @@ -65,7 +65,7 @@ export async function findTests( }); for (const match of globMatches) { - resolvedTestFiles.add(match); + resolvedTestFiles.add(toPosixPath(match)); } } @@ -261,15 +261,15 @@ async function resolveStaticPattern( for (const infix of TEST_FILE_INFIXES) { const potentialSpec = join(dirname(fullPath), `${baseName}${infix}${fileExt}`); if (await exists(potentialSpec)) { - return { resolved: [potentialSpec], unresolved: [] }; + return { resolved: [toPosixPath(potentialSpec)], unresolved: [] }; } } if (await exists(fullPath)) { - return { resolved: [fullPath], unresolved: [] }; + return { resolved: [toPosixPath(fullPath)], unresolved: [] }; } - return { resolved: [], unresolved: [pattern] }; + return { resolved: [], unresolved: [toPosixPath(pattern)] }; } /** Checks if a path exists and is a directory. */ diff --git a/tests/legacy-cli/e2e/tests/vitest/absolute-include.ts b/tests/legacy-cli/e2e/tests/vitest/absolute-include.ts deleted file mode 100644 index 787fe942edbd..000000000000 --- a/tests/legacy-cli/e2e/tests/vitest/absolute-include.ts +++ /dev/null @@ -1,12 +0,0 @@ -import assert from 'node:assert/strict'; -import { applyVitestBuilder } from '../../utils/vitest'; -import { ng } from '../../utils/process'; -import path from 'node:path'; - -export default async function (): Promise { - await applyVitestBuilder(); - - const { stdout } = await ng('test', '--include', path.resolve('src/app/app.spec.ts')); - - assert.match(stdout, /1 passed/, 'Expected 1 test to pass.'); -} diff --git a/tests/legacy-cli/e2e/tests/vitest/include.ts b/tests/legacy-cli/e2e/tests/vitest/include.ts new file mode 100644 index 000000000000..4585194ef3c2 --- /dev/null +++ b/tests/legacy-cli/e2e/tests/vitest/include.ts @@ -0,0 +1,14 @@ +import assert from 'node:assert/strict'; +import { applyVitestBuilder } from '../../utils/vitest'; +import { ng } from '../../utils/process'; +import path from 'node:path'; + +export default async function (): Promise { + await applyVitestBuilder(); + + const { stdout: stdout1 } = await ng('test', '--include', path.resolve('src/app/app.spec.ts')); + assert.match(stdout1, /1 passed/, 'Expected 1 test to pass with absolute include.'); + + const { stdout: stdout2 } = await ng('test', '--include', path.normalize('src/app/app.spec.ts')); + assert.match(stdout2, /1 passed/, 'Expected 1 test to pass with relative include.'); +}