The expect() method name (must start with 'to').
The matcher function (use createUI5Matcher to create one).
Allow users to extend Praman's assertion vocabulary with domain-specific matchers that use the same semantics as built-in matchers.
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');
Registers a custom UI5 matcher for use with
expect(control).toXxx().