Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ancestor and Properties matchers are not extending generic matcher control #4179

Open
C5233991 opened this issue Jan 3, 2025 · 1 comment

Comments

@C5233991
Copy link

C5233991 commented Jan 3, 2025

sap/ui/test/matchers/Ancestor and sap/ui/test/matchers/Properties classes are not inheriting the generic class (in contrast to other matcher classes laying in sap/ui/test/matchers path). Therefore, passing these 2 classes as matchers to waitFor call causes type error like Type 'Ancestor' is not assignable to type 'Matcher | Matcher[]'.ts.

Checked in @sapui5/[email protected]

@codeworrior
Copy link
Member

codeworrior commented Jan 3, 2025

Same is true for sap/ui/test/matchers/Descendant and sap/ui/test/matchers/Sibling. Technically, those four matcher implementations indeed do not extend the Matcher base class and that's valid for Opa5. The type of waitFor's matchers property expects one or multiple values of type sap.ui.test.Opa5.Matcher which is a union:

declare module "sap/ui/test/Opa5" {
  ...
  import UI5Element from "sap/ui/core/Element";
  import Matcher1 from "sap/ui/test/matchers/Matcher";
  ...
  /**
   * Matchers used to filter controls.
   */
  export type Matcher =
    | ((p1: UI5Element) => void) // this is intended to match the 4 implementations under. discussion
    | Record<string, object>
    | Matcher1;
}

The problem is that the four matchers don't document their constructors to return a function matching the first variant of the union type.

Maybe documenting them as a @class doesn't work out and they rather should be documented as factory @functions. I first have to check how this can be represented correctly in JSDoc and then let the owners of the OPA5 APIs know.

Until then, you only can cast the matchers.

BTW: void in the signature of the first variant is nonsense, should be boolean or any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants