MCPcopy Create free account
hub / github.com/angular/components / getHarnessAtIndex

Function getHarnessAtIndex

src/cdk/testing/harness-environment.ts:261–273  ·  view source on GitHub ↗

* Searches for an instance of the component corresponding to the given harness type and index * under the `HarnessEnvironment`'s root element, and returns a `ComponentHarness` for that * instance. The index specifies the offset of the component to find. If no matching * component is found a

(
    query: HarnessQuery<T>,
    offset: number,
  )

Source from the content-addressed store, hash-verified

259 * @throws If a matching component instance can't be found.
260 */
261 async getHarnessAtIndex<T extends ComponentHarness>(
262 query: HarnessQuery<T>,
263 offset: number,
264 ): Promise<T> {
265 if (offset < 0) {
266 throw Error('Index must not be negative');
267 }
268 const harnesses = await this.locatorForAll(query)();
269 if (offset >= harnesses.length) {
270 throw Error(`No harness was located at index ${offset}`);
271 }
272 return harnesses[offset];
273 }
274
275 /**
276 * Searches for all instances of the component corresponding to the given harness type under the

Callers

nothing calls this directly

Calls 1

locatorForAllMethod · 0.80

Tested by

no test coverage detected