|
f7eb47b…
|
lmata
|
1 |
"use strict"; |
|
f7eb47b…
|
lmata
|
2 |
var __defProp = Object.defineProperty; |
|
f7eb47b…
|
lmata
|
3 |
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
|
f7eb47b…
|
lmata
|
4 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
|
f7eb47b…
|
lmata
|
5 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
|
f7eb47b…
|
lmata
|
6 |
var __export = (target, all) => { |
|
f7eb47b…
|
lmata
|
7 |
for (var name in all) |
|
f7eb47b…
|
lmata
|
8 |
__defProp(target, name, { get: all[name], enumerable: true }); |
|
f7eb47b…
|
lmata
|
9 |
}; |
|
f7eb47b…
|
lmata
|
10 |
var __copyProps = (to, from, except, desc) => { |
|
f7eb47b…
|
lmata
|
11 |
if (from && typeof from === "object" || typeof from === "function") { |
|
f7eb47b…
|
lmata
|
12 |
for (let key of __getOwnPropNames(from)) |
|
f7eb47b…
|
lmata
|
13 |
if (!__hasOwnProp.call(to, key) && key !== except) |
|
f7eb47b…
|
lmata
|
14 |
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
|
f7eb47b…
|
lmata
|
15 |
} |
|
f7eb47b…
|
lmata
|
16 |
return to; |
|
f7eb47b…
|
lmata
|
17 |
}; |
|
f7eb47b…
|
lmata
|
18 |
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
|
f7eb47b…
|
lmata
|
19 |
var toMatchText_exports = {}; |
|
f7eb47b…
|
lmata
|
20 |
__export(toMatchText_exports, { |
|
f7eb47b…
|
lmata
|
21 |
toMatchText: () => toMatchText |
|
f7eb47b…
|
lmata
|
22 |
}); |
|
f7eb47b…
|
lmata
|
23 |
module.exports = __toCommonJS(toMatchText_exports); |
|
f7eb47b…
|
lmata
|
24 |
var import_utils = require("playwright-core/lib/utils"); |
|
f7eb47b…
|
lmata
|
25 |
var import_util = require("../util"); |
|
f7eb47b…
|
lmata
|
26 |
async function toMatchText(matcherName, receiver, receiverType, query, expected, options = {}) { |
|
f7eb47b…
|
lmata
|
27 |
(0, import_util.expectTypes)(receiver, [receiverType], matcherName); |
|
f7eb47b…
|
lmata
|
28 |
const locator = receiverType === "Locator" ? receiver : void 0; |
|
f7eb47b…
|
lmata
|
29 |
if (!(typeof expected === "string") && !(expected && typeof expected.test === "function")) { |
|
f7eb47b…
|
lmata
|
30 |
const errorMessage2 = `Error: ${this.utils.EXPECTED_COLOR("expected")} value must be a string or regular expression |
|
f7eb47b…
|
lmata
|
31 |
${this.utils.printWithType("Expected", expected, this.utils.printExpected)}`; |
|
f7eb47b…
|
lmata
|
32 |
throw new Error((0, import_utils.formatMatcherMessage)(this.utils, { promise: this.promise, isNot: this.isNot, locator: locator?.toString(), matcherName, expectation: "expected", errorMessage: errorMessage2 })); |
|
f7eb47b…
|
lmata
|
33 |
} |
|
f7eb47b…
|
lmata
|
34 |
const timeout = options.timeout ?? this.timeout; |
|
f7eb47b…
|
lmata
|
35 |
const { matches: pass, received, log, timedOut, errorMessage } = await query(!!this.isNot, timeout); |
|
f7eb47b…
|
lmata
|
36 |
if (pass === !this.isNot) { |
|
f7eb47b…
|
lmata
|
37 |
return { |
|
f7eb47b…
|
lmata
|
38 |
name: matcherName, |
|
f7eb47b…
|
lmata
|
39 |
message: () => "", |
|
f7eb47b…
|
lmata
|
40 |
pass, |
|
f7eb47b…
|
lmata
|
41 |
expected |
|
f7eb47b…
|
lmata
|
42 |
}; |
|
f7eb47b…
|
lmata
|
43 |
} |
|
f7eb47b…
|
lmata
|
44 |
const expectedSuffix = typeof expected === "string" ? options.matchSubstring ? " substring" : "" : " pattern"; |
|
f7eb47b…
|
lmata
|
45 |
const receivedSuffix = typeof expected === "string" ? options.matchSubstring ? " string" : "" : " string"; |
|
f7eb47b…
|
lmata
|
46 |
const receivedString = received || ""; |
|
f7eb47b…
|
lmata
|
47 |
let printedReceived; |
|
f7eb47b…
|
lmata
|
48 |
let printedExpected; |
|
f7eb47b…
|
lmata
|
49 |
let printedDiff; |
|
f7eb47b…
|
lmata
|
50 |
if (pass) { |
|
f7eb47b…
|
lmata
|
51 |
if (typeof expected === "string") { |
|
f7eb47b…
|
lmata
|
52 |
printedExpected = `Expected${expectedSuffix}: not ${this.utils.printExpected(expected)}`; |
|
f7eb47b…
|
lmata
|
53 |
if (!errorMessage) { |
|
f7eb47b…
|
lmata
|
54 |
const formattedReceived = (0, import_utils.printReceivedStringContainExpectedSubstring)(this.utils, receivedString, receivedString.indexOf(expected), expected.length); |
|
f7eb47b…
|
lmata
|
55 |
printedReceived = `Received${receivedSuffix}: ${formattedReceived}`; |
|
f7eb47b…
|
lmata
|
56 |
} |
|
f7eb47b…
|
lmata
|
57 |
} else { |
|
f7eb47b…
|
lmata
|
58 |
printedExpected = `Expected${expectedSuffix}: not ${this.utils.printExpected(expected)}`; |
|
f7eb47b…
|
lmata
|
59 |
if (!errorMessage) { |
|
f7eb47b…
|
lmata
|
60 |
const formattedReceived = (0, import_utils.printReceivedStringContainExpectedResult)(this.utils, receivedString, typeof expected.exec === "function" ? expected.exec(receivedString) : null); |
|
f7eb47b…
|
lmata
|
61 |
printedReceived = `Received${receivedSuffix}: ${formattedReceived}`; |
|
f7eb47b…
|
lmata
|
62 |
} |
|
f7eb47b…
|
lmata
|
63 |
} |
|
f7eb47b…
|
lmata
|
64 |
} else { |
|
f7eb47b…
|
lmata
|
65 |
if (errorMessage) |
|
f7eb47b…
|
lmata
|
66 |
printedExpected = `Expected${expectedSuffix}: ${this.utils.printExpected(expected)}`; |
|
f7eb47b…
|
lmata
|
67 |
else |
|
f7eb47b…
|
lmata
|
68 |
printedDiff = this.utils.printDiffOrStringify(expected, receivedString, `Expected${expectedSuffix}`, `Received${receivedSuffix}`, false); |
|
f7eb47b…
|
lmata
|
69 |
} |
|
f7eb47b…
|
lmata
|
70 |
const message = () => { |
|
f7eb47b…
|
lmata
|
71 |
return (0, import_utils.formatMatcherMessage)(this.utils, { |
|
f7eb47b…
|
lmata
|
72 |
promise: this.promise, |
|
f7eb47b…
|
lmata
|
73 |
isNot: this.isNot, |
|
f7eb47b…
|
lmata
|
74 |
matcherName, |
|
f7eb47b…
|
lmata
|
75 |
expectation: "expected", |
|
f7eb47b…
|
lmata
|
76 |
locator: locator?.toString(), |
|
f7eb47b…
|
lmata
|
77 |
timeout, |
|
f7eb47b…
|
lmata
|
78 |
timedOut, |
|
f7eb47b…
|
lmata
|
79 |
printedExpected, |
|
f7eb47b…
|
lmata
|
80 |
printedReceived, |
|
f7eb47b…
|
lmata
|
81 |
printedDiff, |
|
f7eb47b…
|
lmata
|
82 |
log, |
|
f7eb47b…
|
lmata
|
83 |
errorMessage |
|
f7eb47b…
|
lmata
|
84 |
}); |
|
f7eb47b…
|
lmata
|
85 |
}; |
|
f7eb47b…
|
lmata
|
86 |
return { |
|
f7eb47b…
|
lmata
|
87 |
name: matcherName, |
|
f7eb47b…
|
lmata
|
88 |
expected, |
|
f7eb47b…
|
lmata
|
89 |
message, |
|
f7eb47b…
|
lmata
|
90 |
pass, |
|
f7eb47b…
|
lmata
|
91 |
actual: received, |
|
f7eb47b…
|
lmata
|
92 |
log, |
|
f7eb47b…
|
lmata
|
93 |
timeout: timedOut ? timeout : void 0 |
|
f7eb47b…
|
lmata
|
94 |
}; |
|
f7eb47b…
|
lmata
|
95 |
} |
|
f7eb47b…
|
lmata
|
96 |
// Annotate the CommonJS export names for ESM import in node: |
|
f7eb47b…
|
lmata
|
97 |
0 && (module.exports = { |
|
f7eb47b…
|
lmata
|
98 |
toMatchText |
|
f7eb47b…
|
lmata
|
99 |
}); |