e2ed
Version:
E2E testing framework over Playwright
30 lines (29 loc) • 1.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyAdditionalMatcher = void 0;
const config_1 = require("../config");
const test_1 = require("@playwright/test");
/**
* Apply additional matcher (with retrying, if needed).
* @internal
*/
const applyAdditionalMatcher = (matcher, ctx, args, selectorPropertyRetryData) => {
if (selectorPropertyRetryData === undefined) {
return matcher.apply(ctx, args).then(() => ctx);
}
const { assertionTimeout } = (0, config_1.getFullPackConfig)();
let context;
return (0, test_1.expect)(() => {
const { args: selectorArgs, property, selector } = selectorPropertyRetryData;
const actualValue = selectorArgs === undefined
? selector[property]
: selector[property](...selectorArgs);
return actualValue.then((value) => {
context = { actualValue: value, description: ctx.description };
return matcher.apply(context, args);
});
}, ctx.description)
.toPass({ timeout: assertionTimeout })
.then(() => context);
};
exports.applyAdditionalMatcher = applyAdditionalMatcher;