diff --git a/packages/angular_devkit/build_angular/src/builders/karma/index.ts b/packages/angular_devkit/build_angular/src/builders/karma/index.ts index 06db2f6e23df..db58042a8406 100644 --- a/packages/angular_devkit/build_angular/src/builders/karma/index.ts +++ b/packages/angular_devkit/build_angular/src/builders/karma/index.ts @@ -118,14 +118,8 @@ export function execute( } const projectMetadata = await context.getProjectMetadata(projectName); - const projectRoot = path.join( - context.workspaceRoot, - (projectMetadata.root as string | undefined) ?? '', - ); - const projectSourceRoot = path.join( - projectRoot, - (projectMetadata.sourceRoot as string | undefined) ?? '', - ); + const sourceRoot = (projectMetadata.sourceRoot ?? projectMetadata.root ?? '') as string; + const projectSourceRoot = path.join(context.workspaceRoot, sourceRoot); const files = await findTests(options.include, context.workspaceRoot, projectSourceRoot); // early exit, no reason to start karma diff --git a/tests/legacy-cli/e2e/tests/test/test-include-glob.ts b/tests/legacy-cli/e2e/tests/test/test-include-glob.ts new file mode 100644 index 000000000000..5dc55edbf8c7 --- /dev/null +++ b/tests/legacy-cli/e2e/tests/test/test-include-glob.ts @@ -0,0 +1,5 @@ +import { ng } from '../../utils/process'; + +export default async function () { + await ng('test', '--no-watch', `--include='**/*.spec.ts'`); +}