Praman — Agent-First SAP UI5 Test Automation Plugin - v1.2.0
    Preparing search index...

    Function registerUI5Matcher

    • Registers a custom UI5 matcher for use with expect(control).toXxx().

      Parameters

      • name: string

        The expect() method name (must start with 'to').

      • matcherFn: UI5MatcherFn

        The matcher function (use createUI5Matcher to create one).

      Returns void

      Allow users to extend Praman's assertion vocabulary with domain-specific matchers that use the same semantics as built-in matchers.

      On success, the matcher is registered and available via expect(control).toXxx().

      Matchers must be registered before the Playwright worker initializes (typically in a playwright.config.ts global setup or a test file's top-level scope). The name must start with to (Playwright convention).

      After the fixture calls applyAll(), the registry is frozen and no further registrations are accepted.

      import { createUI5Matcher, registerUI5Matcher } from 'playwright-praman';

      const checkUI5Icon = createUI5Matcher<[string]>(
      async (page, controlId, expected) => {
      const actual = await getControlProperty(page, controlId, 'icon');
      return {
      pass: actual === expected,
      message: () => `Expected icon '${expected}', got '${String(actual)}'`,
      };
      },
      );

      registerUI5Matcher('toHaveUI5Icon', checkUI5Icon);

      // Now usable in tests:
      // await expect(page).toHaveUI5Icon('sap-icon://add');