ScuttleBot

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

Keyboard Shortcuts

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