ScuttleBot

Blame History Raw 101 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 toEqual_exports = {};
20
__export(toEqual_exports, {
21
toEqual: () => toEqual
22
});
23
module.exports = __toCommonJS(toEqual_exports);
24
var import_utils = require("playwright-core/lib/utils");
25
var import_util = require("../util");
26
const EXPECTED_LABEL = "Expected";
27
const RECEIVED_LABEL = "Received";
28
async function toEqual(matcherName, locator, receiverType, query, expected, options = {}) {
29
(0, import_util.expectTypes)(locator, [receiverType], matcherName);
30
const timeout = options.timeout ?? this.timeout;
31
const { matches: pass, received, log, timedOut, errorMessage } = await query(!!this.isNot, timeout);
32
if (pass === !this.isNot) {
33
return {
34
name: matcherName,
35
message: () => "",
36
pass,
37
expected
38
};
39
}
40
let printedReceived;
41
let printedExpected;
42
let printedDiff;
43
if (pass) {
44
printedExpected = `Expected: not ${this.utils.printExpected(expected)}`;
45
printedReceived = errorMessage ? "" : `Received: ${this.utils.printReceived(received)}`;
46
} else if (errorMessage) {
47
printedExpected = `Expected: ${this.utils.printExpected(expected)}`;
48
} else if (Array.isArray(expected) && Array.isArray(received)) {
49
const normalizedExpected = expected.map((exp, index) => {
50
const rec = received[index];
51
if ((0, import_utils.isRegExp)(exp))
52
return exp.test(rec) ? rec : exp;
53
return exp;
54
});
55
printedDiff = this.utils.printDiffOrStringify(
56
normalizedExpected,
57
received,
58
EXPECTED_LABEL,
59
RECEIVED_LABEL,
60
false
61
);
62
} else {
63
printedDiff = this.utils.printDiffOrStringify(
64
expected,
65
received,
66
EXPECTED_LABEL,
67
RECEIVED_LABEL,
68
false
69
);
70
}
71
const message = () => {
72
return (0, import_utils.formatMatcherMessage)(this.utils, {
73
isNot: this.isNot,
74
promise: this.promise,
75
matcherName,
76
expectation: "expected",
77
locator: locator.toString(),
78
timeout,
79
timedOut,
80
printedExpected,
81
printedReceived,
82
printedDiff,
83
errorMessage,
84
log
85
});
86
};
87
return {
88
actual: received,
89
expected,
90
message,
91
name: matcherName,
92
pass,
93
log,
94
timeout: timedOut ? timeout : void 0
95
};
96
}
97
// Annotate the CommonJS export names for ESM import in node:
98
0 && (module.exports = {
99
toEqual
100
});
101

Keyboard Shortcuts

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