LocatorFnResult
Type Alias
The result type obtained when searching using a particular list of queries. This type depends on the particular items being queried.
- If one of the queries is for a
ComponentHarnessConstructor<C1>
, it means that the result might be a harness of typeC1
- If one of the queries is for a
HarnessPredicate<C2>
, it means that the result might be a harness of typeC2
- If one of the queries is for a
string
, it means that the result might be aTestElement
.
API
type LocatorFnResult<T extends (HarnessQuery<any> | string)[]> = { [I in keyof T]: T[I] extends new (...args: any[]) => infer C // Map `ComponentHarnessConstructor<C>` to `C`. ? C : // Map `HarnessPredicate<C>` to `C`. T[I] extends {harnessType: new (...args: any[]) => infer C} ? C : // Map `string` to `TestElement`. T[I] extends string ? TestElement : // Map everything else to `never` (should not happen due to the type constraint on `T`). never;}[number]
Description
The result type obtained when searching using a particular list of queries. This type depends on the particular items being queried.
- If one of the queries is for a
ComponentHarnessConstructor<C1>
, it means that the result might be a harness of typeC1
- If one of the queries is for a
HarnessPredicate<C2>
, it means that the result might be a harness of typeC2
- If one of the queries is for a
string
, it means that the result might be aTestElement
.
Since we don't know for sure which query will match, the result type if the union of the types for all possible results.
Usage Notes
Example
The type:
LocatorFnResult<[ ComponentHarnessConstructor<MyHarness>, HarnessPredicate<MyOtherHarness>, string]>
is equivalent to:
MyHarness | MyOtherHarness | TestElement
Jump to details