ScuttleBot

scuttlebot / tests / e2e / node_modules / playwright / lib / matchers / toBeTruthy.js
Blame History Raw 76 lines
1
"use strict";
2
var __defProp = Object.defineProperty;
3
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
var __getOwnPropNames = Object.getOwnPropertyNames;
5
var __hasOwnProp = Object.prototype.hasOwnProperty;
6
var __export = (target, all) => {
7
for (var name in all)
8
__defProp(target, name, { get: all[name], enumerable: true });
9
};
10
var __copyProps = (to, from, except, desc) => {
11
if (from && typeof from === "object" || typeof from === "function") {
12
for (let key of __getOwnPropNames(from))
13
if (!__hasOwnProp.call(to, key) && key !== except)
14
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
}
16
return to;
17
};
18
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
var toBeTruthy_exports = {};
20
__export(toBeTruthy_exports, {
21
toBeTruthy: () => toBeTruthy
22
});
23
module.exports = __toCommonJS(toBeTruthy_exports);
24
var import_utils = require("playwright-core/lib/utils");
25
var import_util = require("../util");
26
async function toBeTruthy(matcherName, locator, receiverType, expected, arg, query, options = {}) {
27
(0, import_util.expectTypes)(locator, [receiverType], matcherName);
28
const timeout = options.timeout ?? this.timeout;
29
const { matches: pass, log, timedOut, received, errorMessage } = await query(!!this.isNot, timeout);
30
if (pass === !this.isNot) {
31
return {
32
name: matcherName,
33
message: () => "",
34
pass,
35
expected
36
};
37
}
38
let printedReceived;
39
let printedExpected;
40
if (pass) {
41
printedExpected = `Expected: not ${expected}`;
42
printedReceived = errorMessage ? "" : `Received: ${expected}`;
43
} else {
44
printedExpected = `Expected: ${expected}`;
45
printedReceived = errorMessage ? "" : `Received: ${received}`;
46
}
47
const message = () => {
48
return (0, import_utils.formatMatcherMessage)(this.utils, {
49
isNot: this.isNot,
50
promise: this.promise,
51
matcherName,
52
expectation: arg,
53
locator: locator.toString(),
54
timeout,
55
timedOut,
56
printedExpected,
57
printedReceived,
58
errorMessage,
59
log
60
});
61
};
62
return {
63
message,
64
pass,
65
actual: received,
66
name: matcherName,
67
expected,
68
log,
69
timeout: timedOut ? timeout : void 0
70
};
71
}
72
// Annotate the CommonJS export names for ESM import in node:
73
0 && (module.exports = {
74
toBeTruthy
75
});
76

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button