Skip to main content
Version: 1.x

Function: createUI5Matcher()

createUI5Matcher<TArgs>(checkFn): UI5MatcherFn

Wraps a raw check function with pollUntilPass auto-retry semantics.

Type Parameters

TArgs

TArgs extends readonly unknown[] = readonly unknown[]

Tuple of additional arguments the check function expects.

Parameters

checkFn

MatcherCheckFn<TArgs>

Raw check function that performs a single assertion attempt.

Returns

UI5MatcherFn

A matcher function with auto-retry, suitable for registerUI5Matcher.

Intent

Provide a factory so custom matchers automatically get web-first retry behavior identical to built-in Praman matchers.

Remarks

The returned function:

  1. Extracts an optional trailing MatcherOptions from the arguments
  2. Calls the user's check function inside pollUntilPass
  3. Returns a standard MatcherResult

Example

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

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

registerUI5Matcher('toHaveUI5Icon', checkUI5Icon);