diff --git a/src/cdk/testing/harness-environment.ts b/src/cdk/testing/harness-environment.ts index 277a842e7f19..671c5eccd8f2 100644 --- a/src/cdk/testing/harness-environment.ts +++ b/src/cdk/testing/harness-environment.ts @@ -181,6 +181,10 @@ export abstract class HarnessEnvironment implements HarnessLoader, LocatorFac private async _getAllHarnessesAndTestElements | string)[]>( queries: T, ): Promise[]> { + if (!queries.length) { + throw Error('CDK Component harness query must contain at least one element.'); + } + const {allQueries, harnessQueries, elementQueries, harnessTypes} = _parseQueries(queries); // Combine all of the queries into one large comma-delimited selector and use it to get all raw