playwright 1.55.0-alpha-2025-07-16 → 1.55.0-alpha-2025-07-17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of playwright might be problematic. Click here for more details.

@@ -25,14 +25,18 @@ __export(matcherHint_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(matcherHint_exports);
27
27
  var import_utils = require("playwright-core/lib/utils");
28
- var import_utils2 = require("playwright-core/lib/utils");
29
28
  const kNoElementsFoundError = "<element(s) not found>";
30
- function matcherHint(state, locator, matcherName, expression, actual, matcherOptions, timeout) {
31
- let header = state.utils.matcherHint(matcherName, expression, actual, matcherOptions).replace(/ \/\/ deep equality/, "") + "\n\n";
32
- if (timeout)
33
- header = import_utils2.colors.red(`Timed out ${timeout}ms waiting for `) + header;
29
+ function matcherHint(state, locator, matcherName, expression, actual, matcherOptions, timeout, expectedReceivedString, preventExtraStatIndent = false) {
30
+ let header = state.utils.matcherHint(matcherName, expression, actual, matcherOptions).replace(/ \/\/ deep equality/, "") + " failed\n\n";
31
+ const extraSpace = preventExtraStatIndent ? "" : " ";
34
32
  if (locator)
35
- header += `Locator: ${String(locator)}
33
+ header += `Locator: ${extraSpace}${String(locator)}
34
+ `;
35
+ if (expectedReceivedString)
36
+ header += `${expectedReceivedString}
37
+ `;
38
+ if (timeout)
39
+ header += `Timeout: ${extraSpace}${timeout}ms
36
40
  `;
37
41
  return header;
38
42
  }
@@ -189,7 +189,7 @@ function toHaveClass(locator, expected, options) {
189
189
  return import_toEqual.toEqual.call(this, "toHaveClass", locator, "Locator", async (isNot, timeout) => {
190
190
  const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
191
191
  return await locator._expect("to.have.class.array", { expectedText, isNot, timeout });
192
- }, expected, options);
192
+ }, expected, options, true);
193
193
  } else {
194
194
  return import_toMatchText.toMatchText.call(this, "toHaveClass", locator, "Locator", async (isNot, timeout) => {
195
195
  const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
@@ -204,7 +204,7 @@ function toContainClass(locator, expected, options) {
204
204
  return import_toEqual.toEqual.call(this, "toContainClass", locator, "Locator", async (isNot, timeout) => {
205
205
  const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
206
206
  return await locator._expect("to.contain.class.array", { expectedText, isNot, timeout });
207
- }, expected, options);
207
+ }, expected, options, true);
208
208
  } else {
209
209
  if ((0, import_utils.isRegExp)(expected))
210
210
  throw new Error(`"expected" argument in toContainClass cannot be a RegExp value`);
@@ -50,10 +50,10 @@ async function toBeTruthy(matcherName, receiver, receiverType, expected, arg, qu
50
50
  printedReceived = `Received: ${notFound ? import_matcherHint.kNoElementsFoundError : received}`;
51
51
  }
52
52
  const message = () => {
53
- const header = (0, import_matcherHint.matcherHint)(this, receiver, matcherName, "locator", arg, matcherOptions, timedOut ? timeout : void 0);
53
+ const header = (0, import_matcherHint.matcherHint)(this, receiver, matcherName, "locator", arg, matcherOptions, timedOut ? timeout : void 0, `${printedExpected}
54
+ ${printedReceived}`);
54
55
  const logText = (0, import_util.callLogText)(log);
55
- return `${header}${printedExpected}
56
- ${printedReceived}${logText}`;
56
+ return `${header}${logText}`;
57
57
  };
58
58
  return {
59
59
  message,
@@ -26,7 +26,7 @@ var import_util = require("../util");
26
26
  var import_matcherHint = require("./matcherHint");
27
27
  const EXPECTED_LABEL = "Expected";
28
28
  const RECEIVED_LABEL = "Received";
29
- async function toEqual(matcherName, receiver, receiverType, query, expected, options = {}) {
29
+ async function toEqual(matcherName, receiver, receiverType, query, expected, options = {}, messagePreventExtraStatIndent) {
30
30
  (0, import_util.expectTypes)(receiver, [receiverType], matcherName);
31
31
  const matcherOptions = {
32
32
  comment: options.contains ? "" : "deep equality",
@@ -73,10 +73,10 @@ async function toEqual(matcherName, receiver, receiverType, query, expected, opt
73
73
  );
74
74
  }
75
75
  const message = () => {
76
- const header = (0, import_matcherHint.matcherHint)(this, receiver, matcherName, "locator", void 0, matcherOptions, timedOut ? timeout : void 0);
77
76
  const details = printedDiff || `${printedExpected}
78
77
  ${printedReceived}`;
79
- return `${header}${details}${(0, import_util.callLogText)(log)}`;
78
+ const header = (0, import_matcherHint.matcherHint)(this, receiver, matcherName, "locator", void 0, matcherOptions, timedOut ? timeout : void 0, details, messagePreventExtraStatIndent);
79
+ return `${header}${(0, import_util.callLogText)(log)}`;
80
80
  };
81
81
  return {
82
82
  actual: received,
@@ -37,7 +37,7 @@ async function toHaveURLWithPredicate(page, expected, options) {
37
37
  throw new Error(
38
38
  [
39
39
  // Always display `expected` in expectation place
40
- (0, import_matcherHint.matcherHint)(this, void 0, matcherName, expression, void 0, matcherOptions),
40
+ (0, import_matcherHint.matcherHint)(this, void 0, matcherName, expression, void 0, matcherOptions, void 0, void 0, true),
41
41
  `${import_utils2.colors.bold("Matcher error")}: ${(0, import_expectBundle.EXPECTED_COLOR)("expected")} value must be a string, regular expression, or predicate`,
42
42
  this.utils.printWithType("Expected", expected, this.utils.printExpected)
43
43
  ].join("\n\n")
@@ -91,7 +91,7 @@ function toHaveURLMessage(state, matcherName, expression, expected, received, pa
91
91
  promise: state.promise
92
92
  };
93
93
  const receivedString = received || "";
94
- const messagePrefix = (0, import_matcherHint.matcherHint)(state, void 0, matcherName, expression, void 0, matcherOptions, didTimeout ? timeout : void 0);
94
+ const messagePrefix = (0, import_matcherHint.matcherHint)(state, void 0, matcherName, expression, void 0, matcherOptions, didTimeout ? timeout : void 0, void 0, true);
95
95
  let printedReceived;
96
96
  let printedExpected;
97
97
  let printedDiff;
@@ -77,13 +77,15 @@ async function toMatchAriaSnapshot(receiver, expectedParam, options = {}) {
77
77
  expected = unshift(expected);
78
78
  const { matches: pass, received, log, timedOut } = await receiver._expect("to.match.aria", { expectedValue: expected, isNot: this.isNot, timeout });
79
79
  const typedReceived = received;
80
- const messagePrefix = (0, import_matcherHint.matcherHint)(this, receiver, matcherName, "locator", void 0, matcherOptions, timedOut ? timeout : void 0);
80
+ const matcherHintWithExpect = (expectedReceivedString) => {
81
+ return (0, import_matcherHint.matcherHint)(this, receiver, matcherName, "locator", void 0, matcherOptions, timedOut ? timeout : void 0, expectedReceivedString);
82
+ };
81
83
  const notFound = typedReceived === import_matcherHint.kNoElementsFoundError;
82
84
  if (notFound) {
83
85
  return {
84
86
  pass: this.isNot,
85
- message: () => messagePrefix + `Expected: ${this.utils.printExpected(expected)}
86
- Received: ${(0, import_expectBundle.EXPECTED_COLOR)("<element not found>")}` + (0, import_util.callLogText)(log),
87
+ message: () => matcherHintWithExpect(`Expected: ${this.utils.printExpected(expected)}
88
+ Received: ${(0, import_expectBundle.EXPECTED_COLOR)("<element not found>")}`) + (0, import_util.callLogText)(log),
87
89
  name: "toMatchAriaSnapshot",
88
90
  expected
89
91
  };
@@ -91,18 +93,15 @@ Received: ${(0, import_expectBundle.EXPECTED_COLOR)("<element not found>")}` + (
91
93
  const receivedText = typedReceived.raw;
92
94
  const message = () => {
93
95
  if (pass) {
94
- if (notFound)
95
- return messagePrefix + `Expected: not ${this.utils.printExpected(expected)}
96
- Received: ${receivedText}` + (0, import_util.callLogText)(log);
97
- const printedReceived = (0, import_expect.printReceivedStringContainExpectedSubstring)(receivedText, receivedText.indexOf(expected), expected.length);
98
- return messagePrefix + `Expected: not ${this.utils.printExpected(expected)}
99
- Received: ${printedReceived}` + (0, import_util.callLogText)(log);
96
+ const receivedString = notFound ? receivedText : (0, import_expect.printReceivedStringContainExpectedSubstring)(receivedText, receivedText.indexOf(expected), expected.length);
97
+ const expectedReceivedString = `Expected: not ${this.utils.printExpected(expected)}
98
+ Received: ${receivedString}`;
99
+ return matcherHintWithExpect(expectedReceivedString) + (0, import_util.callLogText)(log);
100
100
  } else {
101
101
  const labelExpected = `Expected`;
102
- if (notFound)
103
- return messagePrefix + `${labelExpected}: ${this.utils.printExpected(expected)}
104
- Received: ${receivedText}` + (0, import_util.callLogText)(log);
105
- return messagePrefix + this.utils.printDiffOrStringify(expected, receivedText, labelExpected, "Received", false) + (0, import_util.callLogText)(log);
102
+ const expectedReceivedString = notFound ? `${labelExpected}: ${this.utils.printExpected(expected)}
103
+ Received: ${receivedText}` : this.utils.printDiffOrStringify(expected, receivedText, labelExpected, "Received", false);
104
+ return matcherHintWithExpect(expectedReceivedString) + (0, import_util.callLogText)(log);
106
105
  }
107
106
  };
108
107
  if (!this.isNot) {
@@ -217,7 +217,7 @@ function toMatchSnapshot(received, nameOrOptions = {}, optOptions = {}) {
217
217
  if (!result)
218
218
  return helper.handleMatching();
219
219
  const receiver = (0, import_utils.isString)(received) ? "string" : "Buffer";
220
- const header = (0, import_matcherHint.matcherHint)(this, void 0, "toMatchSnapshot", receiver, void 0, void 0);
220
+ const header = (0, import_matcherHint.matcherHint)(this, void 0, "toMatchSnapshot", receiver, void 0, void 0, void 0);
221
221
  return helper.handleDifferent(received, expected, void 0, result.diff, header, result.errorMessage, void 0, this._stepInfo);
222
222
  }
223
223
  function toHaveScreenshotStepTitle(nameOrOptions = {}, optOptions = {}) {
@@ -34,7 +34,7 @@ async function toMatchText(matcherName, receiver, receiverType, query, expected,
34
34
  };
35
35
  if (!(typeof expected === "string") && !(expected && typeof expected.test === "function")) {
36
36
  throw new Error([
37
- (0, import_matcherHint.matcherHint)(this, receiverType === "Locator" ? receiver : void 0, matcherName, options.receiverLabel ?? receiver, expected, matcherOptions),
37
+ (0, import_matcherHint.matcherHint)(this, receiverType === "Locator" ? receiver : void 0, matcherName, options.receiverLabel ?? receiver, expected, matcherOptions, void 0, void 0, true),
38
38
  `${import_utils.colors.bold("Matcher error")}: ${(0, import_expectBundle.EXPECTED_COLOR)("expected")} value must be a string or regular expression`,
39
39
  this.utils.printWithType("Expected", expected, this.utils.printExpected)
40
40
  ].join("\n\n"));
@@ -51,7 +51,6 @@ async function toMatchText(matcherName, receiver, receiverType, query, expected,
51
51
  }
52
52
  const stringSubstring = options.matchSubstring ? "substring" : "string";
53
53
  const receivedString = received || "";
54
- const messagePrefix = (0, import_matcherHint.matcherHint)(this, receiverType === "Locator" ? receiver : void 0, matcherName, options.receiverLabel ?? "locator", void 0, matcherOptions, timedOut ? timeout : void 0);
55
54
  const notFound = received === import_matcherHint.kNoElementsFoundError;
56
55
  let printedReceived;
57
56
  let printedExpected;
@@ -87,7 +86,8 @@ async function toMatchText(matcherName, receiver, receiverType, query, expected,
87
86
  }
88
87
  const message = () => {
89
88
  const resultDetails = printedDiff ? printedDiff : printedExpected + "\n" + printedReceived;
90
- return messagePrefix + resultDetails + (0, import_util.callLogText)(log);
89
+ const hints = (0, import_matcherHint.matcherHint)(this, receiverType === "Locator" ? receiver : void 0, matcherName, options.receiverLabel ?? "locator", void 0, matcherOptions, timedOut ? timeout : void 0, resultDetails, true);
90
+ return hints + (0, import_util.callLogText)(log);
91
91
  };
92
92
  return {
93
93
  name: matcherName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playwright",
3
- "version": "1.55.0-alpha-2025-07-16",
3
+ "version": "1.55.0-alpha-2025-07-17",
4
4
  "description": "A high-level API to automate web browsers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "license": "Apache-2.0",
58
58
  "dependencies": {
59
- "playwright-core": "1.55.0-alpha-2025-07-16"
59
+ "playwright-core": "1.55.0-alpha-2025-07-17"
60
60
  },
61
61
  "optionalDependencies": {
62
62
  "fsevents": "2.3.2"