UNPKG

expect-playwright

Version:

![Node.js CI](https://github.com/playwright-community/expect-playwright/workflows/Node.js%20CI/badge.svg) [![codecov](https://codecov.io/gh/playwright-community/expect-playwright/branch/master/graph/badge.svg?token=Eay491HC49)](https://codecov.io/gh/playw

27 lines (26 loc) 887 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const utils_1 = require("../utils"); const toHaveSelector = async function (arg, selector, options = {}) { const pass = await utils_1.getElementHandle([ arg, selector, { state: this.isNot ? "hidden" : "visible", ...options, }, ], 0) .then(() => !this.isNot) .catch(() => this.isNot); return { pass: pass, message: () => { const not = this.isNot ? " not" : ""; const hint = this.utils.matcherHint("toHaveSelector", undefined, undefined, { isNot: this.isNot, promise: this.promise }); return (hint + "\n\n" + `Expected: page to${not} have selector ${this.utils.printExpected(selector)}`); }, }; }; exports.default = toHaveSelector;