patchright-bun 1.58.1 → 1.59.0

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.
Files changed (183) hide show
  1. package/README.md +225 -225
  2. package/ThirdPartyNotices.txt +3918 -5041
  3. package/cli.js +19 -19
  4. package/index.d.ts +17 -17
  5. package/index.js +17 -17
  6. package/index.mjs +18 -18
  7. package/jsx-runtime.js +42 -42
  8. package/jsx-runtime.mjs +21 -21
  9. package/lib/agents/agentParser.js +89 -89
  10. package/lib/agents/copilot-setup-steps.yml +34 -34
  11. package/lib/agents/generateAgents.js +346 -348
  12. package/lib/agents/playwright-test-coverage.prompt.md +31 -31
  13. package/lib/agents/playwright-test-generate.prompt.md +8 -8
  14. package/lib/agents/playwright-test-generator.agent.md +88 -88
  15. package/lib/agents/playwright-test-heal.prompt.md +6 -6
  16. package/lib/agents/playwright-test-healer.agent.md +55 -55
  17. package/lib/agents/playwright-test-plan.prompt.md +9 -9
  18. package/lib/agents/playwright-test-planner.agent.md +73 -73
  19. package/lib/common/config.js +281 -282
  20. package/lib/common/configLoader.js +344 -344
  21. package/lib/common/esmLoaderHost.js +104 -104
  22. package/lib/common/expectBundle.js +28 -28
  23. package/lib/common/expectBundleImpl.js +407 -407
  24. package/lib/common/fixtures.js +302 -302
  25. package/lib/common/globals.js +58 -58
  26. package/lib/common/ipc.js +60 -60
  27. package/lib/common/poolBuilder.js +85 -85
  28. package/lib/common/process.js +133 -132
  29. package/lib/common/suiteUtils.js +140 -140
  30. package/lib/common/test.js +330 -321
  31. package/lib/common/testLoader.js +101 -101
  32. package/lib/common/testType.js +301 -298
  33. package/lib/common/validators.js +68 -68
  34. package/lib/errorContext.js +121 -0
  35. package/lib/fsWatcher.js +67 -67
  36. package/lib/index.js +764 -726
  37. package/lib/internalsForTest.js +42 -42
  38. package/lib/isomorphic/events.js +77 -77
  39. package/lib/isomorphic/folders.js +30 -30
  40. package/lib/isomorphic/stringInternPool.js +69 -69
  41. package/lib/isomorphic/teleReceiver.js +538 -521
  42. package/lib/isomorphic/teleSuiteUpdater.js +157 -157
  43. package/lib/isomorphic/testServerConnection.js +223 -225
  44. package/lib/isomorphic/testServerInterface.js +16 -16
  45. package/lib/isomorphic/testTree.js +329 -329
  46. package/lib/isomorphic/types.d.js +16 -16
  47. package/lib/loader/loaderMain.js +59 -59
  48. package/lib/matchers/expect.js +311 -311
  49. package/lib/matchers/matcherHint.js +44 -44
  50. package/lib/matchers/matchers.js +385 -383
  51. package/lib/matchers/toBeTruthy.js +75 -75
  52. package/lib/matchers/toEqual.js +100 -100
  53. package/lib/matchers/toHaveURL.js +101 -101
  54. package/lib/matchers/toMatchAriaSnapshot.js +163 -159
  55. package/lib/matchers/toMatchSnapshot.js +349 -342
  56. package/lib/matchers/toMatchText.js +99 -99
  57. package/lib/mcp/test/browserBackend.js +121 -98
  58. package/lib/mcp/test/generatorTools.js +122 -122
  59. package/lib/mcp/test/plannerTools.js +145 -145
  60. package/lib/mcp/test/seed.js +82 -82
  61. package/lib/mcp/test/streams.js +44 -44
  62. package/lib/mcp/test/testBackend.js +99 -99
  63. package/lib/mcp/test/testContext.js +283 -285
  64. package/lib/mcp/test/testTool.js +30 -30
  65. package/lib/mcp/test/testTools.js +108 -108
  66. package/lib/plugins/gitCommitInfoPlugin.js +198 -198
  67. package/lib/plugins/index.js +28 -28
  68. package/lib/plugins/webServerPlugin.js +238 -237
  69. package/lib/program.js +239 -417
  70. package/lib/reportActions.js +80 -0
  71. package/lib/reporters/base.js +633 -634
  72. package/lib/reporters/blob.js +138 -138
  73. package/lib/reporters/dot.js +99 -99
  74. package/lib/reporters/empty.js +32 -32
  75. package/lib/reporters/github.js +127 -128
  76. package/lib/reporters/html.js +666 -633
  77. package/lib/reporters/internalReporter.js +138 -138
  78. package/lib/reporters/json.js +254 -254
  79. package/lib/reporters/junit.js +321 -232
  80. package/lib/reporters/line.js +131 -131
  81. package/lib/reporters/list.js +252 -253
  82. package/lib/reporters/listModeReporter.js +69 -69
  83. package/lib/reporters/markdown.js +144 -144
  84. package/lib/reporters/merge.js +579 -558
  85. package/lib/reporters/multiplexer.js +116 -112
  86. package/lib/reporters/reporterV2.js +102 -102
  87. package/lib/reporters/teleEmitter.js +319 -317
  88. package/lib/reporters/versions/blobV1.js +16 -16
  89. package/lib/runner/dispatcher.js +522 -530
  90. package/lib/runner/failureTracker.js +72 -72
  91. package/lib/runner/lastRun.js +77 -77
  92. package/lib/runner/loadUtils.js +340 -334
  93. package/lib/runner/loaderHost.js +89 -89
  94. package/lib/runner/processHost.js +180 -180
  95. package/lib/runner/projectUtils.js +241 -241
  96. package/lib/runner/rebase.js +189 -189
  97. package/lib/runner/reporters.js +143 -138
  98. package/lib/runner/sigIntWatcher.js +96 -96
  99. package/lib/runner/taskRunner.js +127 -127
  100. package/lib/runner/tasks.js +413 -410
  101. package/lib/runner/testGroups.js +125 -125
  102. package/lib/runner/testRunner.js +398 -398
  103. package/lib/runner/testServer.js +269 -269
  104. package/lib/runner/uiModeReporter.js +30 -30
  105. package/lib/runner/vcs.js +72 -72
  106. package/lib/runner/watchMode.js +396 -396
  107. package/lib/runner/workerHost.js +101 -104
  108. package/lib/testActions.js +220 -0
  109. package/lib/third_party/pirates.js +62 -62
  110. package/lib/third_party/tsconfig-loader.js +103 -103
  111. package/lib/transform/babelBundle.js +43 -46
  112. package/lib/transform/babelBundleImpl.js +461 -461
  113. package/lib/transform/compilationCache.js +272 -274
  114. package/lib/transform/esmLoader.js +105 -103
  115. package/lib/transform/portTransport.js +67 -67
  116. package/lib/transform/transform.js +296 -303
  117. package/lib/util.js +400 -400
  118. package/lib/utilsBundle.js +43 -50
  119. package/lib/utilsBundleImpl.js +100 -103
  120. package/lib/worker/fixtureRunner.js +262 -262
  121. package/lib/worker/testInfo.js +532 -536
  122. package/lib/worker/testTracing.js +351 -345
  123. package/lib/worker/timeoutManager.js +185 -174
  124. package/lib/worker/util.js +31 -31
  125. package/lib/worker/workerMain.js +533 -530
  126. package/package.json +2 -6
  127. package/test.d.ts +18 -18
  128. package/test.js +24 -24
  129. package/test.mjs +34 -34
  130. package/types/test.d.ts +10322 -10251
  131. package/types/testReporter.d.ts +822 -822
  132. package/lib/mcp/browser/browserContextFactory.js +0 -329
  133. package/lib/mcp/browser/browserServerBackend.js +0 -84
  134. package/lib/mcp/browser/config.js +0 -421
  135. package/lib/mcp/browser/context.js +0 -244
  136. package/lib/mcp/browser/response.js +0 -278
  137. package/lib/mcp/browser/sessionLog.js +0 -75
  138. package/lib/mcp/browser/tab.js +0 -343
  139. package/lib/mcp/browser/tools/common.js +0 -65
  140. package/lib/mcp/browser/tools/console.js +0 -46
  141. package/lib/mcp/browser/tools/dialogs.js +0 -60
  142. package/lib/mcp/browser/tools/evaluate.js +0 -61
  143. package/lib/mcp/browser/tools/files.js +0 -58
  144. package/lib/mcp/browser/tools/form.js +0 -63
  145. package/lib/mcp/browser/tools/install.js +0 -72
  146. package/lib/mcp/browser/tools/keyboard.js +0 -107
  147. package/lib/mcp/browser/tools/mouse.js +0 -107
  148. package/lib/mcp/browser/tools/navigate.js +0 -71
  149. package/lib/mcp/browser/tools/network.js +0 -63
  150. package/lib/mcp/browser/tools/open.js +0 -57
  151. package/lib/mcp/browser/tools/pdf.js +0 -49
  152. package/lib/mcp/browser/tools/runCode.js +0 -78
  153. package/lib/mcp/browser/tools/screenshot.js +0 -93
  154. package/lib/mcp/browser/tools/snapshot.js +0 -173
  155. package/lib/mcp/browser/tools/tabs.js +0 -67
  156. package/lib/mcp/browser/tools/tool.js +0 -47
  157. package/lib/mcp/browser/tools/tracing.js +0 -74
  158. package/lib/mcp/browser/tools/utils.js +0 -94
  159. package/lib/mcp/browser/tools/verify.js +0 -143
  160. package/lib/mcp/browser/tools/wait.js +0 -63
  161. package/lib/mcp/browser/tools.js +0 -84
  162. package/lib/mcp/browser/watchdog.js +0 -44
  163. package/lib/mcp/config.d.js +0 -16
  164. package/lib/mcp/extension/cdpRelay.js +0 -351
  165. package/lib/mcp/extension/extensionContextFactory.js +0 -76
  166. package/lib/mcp/extension/protocol.js +0 -28
  167. package/lib/mcp/index.js +0 -61
  168. package/lib/mcp/log.js +0 -35
  169. package/lib/mcp/program.js +0 -111
  170. package/lib/mcp/sdk/exports.js +0 -28
  171. package/lib/mcp/sdk/http.js +0 -152
  172. package/lib/mcp/sdk/inProcessTransport.js +0 -71
  173. package/lib/mcp/sdk/server.js +0 -223
  174. package/lib/mcp/sdk/tool.js +0 -47
  175. package/lib/mcp/terminal/cli.js +0 -296
  176. package/lib/mcp/terminal/command.js +0 -56
  177. package/lib/mcp/terminal/commands.js +0 -333
  178. package/lib/mcp/terminal/daemon.js +0 -129
  179. package/lib/mcp/terminal/help.json +0 -32
  180. package/lib/mcp/terminal/helpGenerator.js +0 -88
  181. package/lib/mcp/terminal/socketConnection.js +0 -80
  182. package/lib/runner/storage.js +0 -91
  183. package/lib/transform/md.js +0 -221
@@ -1,383 +1,385 @@
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 matchers_exports = {};
20
- __export(matchers_exports, {
21
- computeMatcherTitleSuffix: () => computeMatcherTitleSuffix,
22
- toBeAttached: () => toBeAttached,
23
- toBeChecked: () => toBeChecked,
24
- toBeDisabled: () => toBeDisabled,
25
- toBeEditable: () => toBeEditable,
26
- toBeEmpty: () => toBeEmpty,
27
- toBeEnabled: () => toBeEnabled,
28
- toBeFocused: () => toBeFocused,
29
- toBeHidden: () => toBeHidden,
30
- toBeInViewport: () => toBeInViewport,
31
- toBeOK: () => toBeOK,
32
- toBeVisible: () => toBeVisible,
33
- toContainClass: () => toContainClass,
34
- toContainText: () => toContainText,
35
- toHaveAccessibleDescription: () => toHaveAccessibleDescription,
36
- toHaveAccessibleErrorMessage: () => toHaveAccessibleErrorMessage,
37
- toHaveAccessibleName: () => toHaveAccessibleName,
38
- toHaveAttribute: () => toHaveAttribute,
39
- toHaveCSS: () => toHaveCSS,
40
- toHaveClass: () => toHaveClass,
41
- toHaveCount: () => toHaveCount,
42
- toHaveId: () => toHaveId,
43
- toHaveJSProperty: () => toHaveJSProperty,
44
- toHaveRole: () => toHaveRole,
45
- toHaveText: () => toHaveText,
46
- toHaveTitle: () => toHaveTitle,
47
- toHaveURL: () => toHaveURL,
48
- toHaveValue: () => toHaveValue,
49
- toHaveValues: () => toHaveValues,
50
- toPass: () => toPass
51
- });
52
- module.exports = __toCommonJS(matchers_exports);
53
- var import_utils = require("patchright-core/lib/utils");
54
- var import_utils2 = require("patchright-core/lib/utils");
55
- var import_util = require("../util");
56
- var import_toBeTruthy = require("./toBeTruthy");
57
- var import_toEqual = require("./toEqual");
58
- var import_toHaveURL = require("./toHaveURL");
59
- var import_toMatchText = require("./toMatchText");
60
- var import_toMatchSnapshot = require("./toMatchSnapshot");
61
- var import_config = require("../common/config");
62
- var import_globals = require("../common/globals");
63
- var import_testInfo = require("../worker/testInfo");
64
- function toBeAttached(locator, options) {
65
- const attached = !options || options.attached === void 0 || options.attached;
66
- const expected = attached ? "attached" : "detached";
67
- const arg = attached ? "" : "{ attached: false }";
68
- return import_toBeTruthy.toBeTruthy.call(this, "toBeAttached", locator, "Locator", expected, arg, async (isNot, timeout) => {
69
- return await locator._expect(attached ? "to.be.attached" : "to.be.detached", { isNot, timeout });
70
- }, options);
71
- }
72
- function toBeChecked(locator, options) {
73
- const checked = options?.checked;
74
- const indeterminate = options?.indeterminate;
75
- const expectedValue = {
76
- checked,
77
- indeterminate
78
- };
79
- let expected;
80
- let arg;
81
- if (options?.indeterminate) {
82
- expected = "indeterminate";
83
- arg = `{ indeterminate: true }`;
84
- } else {
85
- expected = options?.checked === false ? "unchecked" : "checked";
86
- arg = options?.checked === false ? `{ checked: false }` : "";
87
- }
88
- return import_toBeTruthy.toBeTruthy.call(this, "toBeChecked", locator, "Locator", expected, arg, async (isNot, timeout) => {
89
- return await locator._expect("to.be.checked", { isNot, timeout, expectedValue });
90
- }, options);
91
- }
92
- function toBeDisabled(locator, options) {
93
- return import_toBeTruthy.toBeTruthy.call(this, "toBeDisabled", locator, "Locator", "disabled", "", async (isNot, timeout) => {
94
- return await locator._expect("to.be.disabled", { isNot, timeout });
95
- }, options);
96
- }
97
- function toBeEditable(locator, options) {
98
- const editable = !options || options.editable === void 0 || options.editable;
99
- const expected = editable ? "editable" : "readOnly";
100
- const arg = editable ? "" : "{ editable: false }";
101
- return import_toBeTruthy.toBeTruthy.call(this, "toBeEditable", locator, "Locator", expected, arg, async (isNot, timeout) => {
102
- return await locator._expect(editable ? "to.be.editable" : "to.be.readonly", { isNot, timeout });
103
- }, options);
104
- }
105
- function toBeEmpty(locator, options) {
106
- return import_toBeTruthy.toBeTruthy.call(this, "toBeEmpty", locator, "Locator", "empty", "", async (isNot, timeout) => {
107
- return await locator._expect("to.be.empty", { isNot, timeout });
108
- }, options);
109
- }
110
- function toBeEnabled(locator, options) {
111
- const enabled = !options || options.enabled === void 0 || options.enabled;
112
- const expected = enabled ? "enabled" : "disabled";
113
- const arg = enabled ? "" : "{ enabled: false }";
114
- return import_toBeTruthy.toBeTruthy.call(this, "toBeEnabled", locator, "Locator", expected, arg, async (isNot, timeout) => {
115
- return await locator._expect(enabled ? "to.be.enabled" : "to.be.disabled", { isNot, timeout });
116
- }, options);
117
- }
118
- function toBeFocused(locator, options) {
119
- return import_toBeTruthy.toBeTruthy.call(this, "toBeFocused", locator, "Locator", "focused", "", async (isNot, timeout) => {
120
- return await locator._expect("to.be.focused", { isNot, timeout });
121
- }, options);
122
- }
123
- function toBeHidden(locator, options) {
124
- return import_toBeTruthy.toBeTruthy.call(this, "toBeHidden", locator, "Locator", "hidden", "", async (isNot, timeout) => {
125
- return await locator._expect("to.be.hidden", { isNot, timeout });
126
- }, options);
127
- }
128
- function toBeVisible(locator, options) {
129
- const visible = !options || options.visible === void 0 || options.visible;
130
- const expected = visible ? "visible" : "hidden";
131
- const arg = visible ? "" : "{ visible: false }";
132
- return import_toBeTruthy.toBeTruthy.call(this, "toBeVisible", locator, "Locator", expected, arg, async (isNot, timeout) => {
133
- return await locator._expect(visible ? "to.be.visible" : "to.be.hidden", { isNot, timeout });
134
- }, options);
135
- }
136
- function toBeInViewport(locator, options) {
137
- return import_toBeTruthy.toBeTruthy.call(this, "toBeInViewport", locator, "Locator", "in viewport", "", async (isNot, timeout) => {
138
- return await locator._expect("to.be.in.viewport", { isNot, expectedNumber: options?.ratio, timeout });
139
- }, options);
140
- }
141
- function toContainText(locator, expected, options = {}) {
142
- if (Array.isArray(expected)) {
143
- return import_toEqual.toEqual.call(this, "toContainText", locator, "Locator", async (isNot, timeout) => {
144
- const expectedText = (0, import_utils.serializeExpectedTextValues)(expected, { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
145
- return await locator._expect("to.contain.text.array", { expectedText, isNot, useInnerText: options.useInnerText, timeout });
146
- }, expected, { ...options, contains: true });
147
- } else {
148
- return import_toMatchText.toMatchText.call(this, "toContainText", locator, "Locator", async (isNot, timeout) => {
149
- const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
150
- return await locator._expect("to.have.text", { expectedText, isNot, useInnerText: options.useInnerText, timeout });
151
- }, expected, { ...options, matchSubstring: true });
152
- }
153
- }
154
- function toHaveAccessibleDescription(locator, expected, options) {
155
- return import_toMatchText.toMatchText.call(this, "toHaveAccessibleDescription", locator, "Locator", async (isNot, timeout) => {
156
- const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
157
- return await locator._expect("to.have.accessible.description", { expectedText, isNot, timeout });
158
- }, expected, options);
159
- }
160
- function toHaveAccessibleName(locator, expected, options) {
161
- return import_toMatchText.toMatchText.call(this, "toHaveAccessibleName", locator, "Locator", async (isNot, timeout) => {
162
- const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
163
- return await locator._expect("to.have.accessible.name", { expectedText, isNot, timeout });
164
- }, expected, options);
165
- }
166
- function toHaveAccessibleErrorMessage(locator, expected, options) {
167
- return import_toMatchText.toMatchText.call(this, "toHaveAccessibleErrorMessage", locator, "Locator", async (isNot, timeout) => {
168
- const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
169
- return await locator._expect("to.have.accessible.error.message", { expectedText, isNot, timeout });
170
- }, expected, options);
171
- }
172
- function toHaveAttribute(locator, name, expected, options) {
173
- if (!options) {
174
- if (typeof expected === "object" && !(0, import_utils.isRegExp)(expected)) {
175
- options = expected;
176
- expected = void 0;
177
- }
178
- }
179
- if (expected === void 0) {
180
- return import_toBeTruthy.toBeTruthy.call(this, "toHaveAttribute", locator, "Locator", "have attribute", "", async (isNot, timeout) => {
181
- return await locator._expect("to.have.attribute", { expressionArg: name, isNot, timeout });
182
- }, options);
183
- }
184
- return import_toMatchText.toMatchText.call(this, "toHaveAttribute", locator, "Locator", async (isNot, timeout) => {
185
- const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase });
186
- return await locator._expect("to.have.attribute.value", { expressionArg: name, expectedText, isNot, timeout });
187
- }, expected, options);
188
- }
189
- function toHaveClass(locator, expected, options) {
190
- if (Array.isArray(expected)) {
191
- return import_toEqual.toEqual.call(this, "toHaveClass", locator, "Locator", async (isNot, timeout) => {
192
- const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
193
- return await locator._expect("to.have.class.array", { expectedText, isNot, timeout });
194
- }, expected, options);
195
- } else {
196
- return import_toMatchText.toMatchText.call(this, "toHaveClass", locator, "Locator", async (isNot, timeout) => {
197
- const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
198
- return await locator._expect("to.have.class", { expectedText, isNot, timeout });
199
- }, expected, options);
200
- }
201
- }
202
- function toContainClass(locator, expected, options) {
203
- if (Array.isArray(expected)) {
204
- if (expected.some((e) => (0, import_utils.isRegExp)(e)))
205
- throw new Error(`"expected" argument in toContainClass cannot contain RegExp values`);
206
- return import_toEqual.toEqual.call(this, "toContainClass", locator, "Locator", async (isNot, timeout) => {
207
- const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
208
- return await locator._expect("to.contain.class.array", { expectedText, isNot, timeout });
209
- }, expected, options);
210
- } else {
211
- if ((0, import_utils.isRegExp)(expected))
212
- throw new Error(`"expected" argument in toContainClass cannot be a RegExp value`);
213
- return import_toMatchText.toMatchText.call(this, "toContainClass", locator, "Locator", async (isNot, timeout) => {
214
- const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
215
- return await locator._expect("to.contain.class", { expectedText, isNot, timeout });
216
- }, expected, options);
217
- }
218
- }
219
- function toHaveCount(locator, expected, options) {
220
- return import_toEqual.toEqual.call(this, "toHaveCount", locator, "Locator", async (isNot, timeout) => {
221
- return await locator._expect("to.have.count", { expectedNumber: expected, isNot, timeout });
222
- }, expected, options);
223
- }
224
- function toHaveCSS(locator, name, expected, options) {
225
- return import_toMatchText.toMatchText.call(this, "toHaveCSS", locator, "Locator", async (isNot, timeout) => {
226
- const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
227
- return await locator._expect("to.have.css", { expressionArg: name, expectedText, isNot, timeout });
228
- }, expected, options);
229
- }
230
- function toHaveId(locator, expected, options) {
231
- return import_toMatchText.toMatchText.call(this, "toHaveId", locator, "Locator", async (isNot, timeout) => {
232
- const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
233
- return await locator._expect("to.have.id", { expectedText, isNot, timeout });
234
- }, expected, options);
235
- }
236
- function toHaveJSProperty(locator, name, expected, options) {
237
- return import_toEqual.toEqual.call(this, "toHaveJSProperty", locator, "Locator", async (isNot, timeout) => {
238
- return await locator._expect("to.have.property", { expressionArg: name, expectedValue: expected, isNot, timeout });
239
- }, expected, options);
240
- }
241
- function toHaveRole(locator, expected, options) {
242
- if (!(0, import_utils.isString)(expected))
243
- throw new Error(`"role" argument in toHaveRole must be a string`);
244
- return import_toMatchText.toMatchText.call(this, "toHaveRole", locator, "Locator", async (isNot, timeout) => {
245
- const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
246
- return await locator._expect("to.have.role", { expectedText, isNot, timeout });
247
- }, expected, options);
248
- }
249
- function toHaveText(locator, expected, options = {}) {
250
- if (Array.isArray(expected)) {
251
- return import_toEqual.toEqual.call(this, "toHaveText", locator, "Locator", async (isNot, timeout) => {
252
- const expectedText = (0, import_utils.serializeExpectedTextValues)(expected, { normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
253
- return await locator._expect("to.have.text.array", { expectedText, isNot, useInnerText: options?.useInnerText, timeout });
254
- }, expected, options);
255
- } else {
256
- return import_toMatchText.toMatchText.call(this, "toHaveText", locator, "Locator", async (isNot, timeout) => {
257
- const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
258
- return await locator._expect("to.have.text", { expectedText, isNot, useInnerText: options?.useInnerText, timeout });
259
- }, expected, options);
260
- }
261
- }
262
- function toHaveValue(locator, expected, options) {
263
- return import_toMatchText.toMatchText.call(this, "toHaveValue", locator, "Locator", async (isNot, timeout) => {
264
- const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
265
- return await locator._expect("to.have.value", { expectedText, isNot, timeout });
266
- }, expected, options);
267
- }
268
- function toHaveValues(locator, expected, options) {
269
- return import_toEqual.toEqual.call(this, "toHaveValues", locator, "Locator", async (isNot, timeout) => {
270
- const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
271
- return await locator._expect("to.have.values", { expectedText, isNot, timeout });
272
- }, expected, options);
273
- }
274
- function toHaveTitle(page, expected, options = {}) {
275
- return import_toMatchText.toMatchText.call(this, "toHaveTitle", page, "Page", async (isNot, timeout) => {
276
- const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { normalizeWhiteSpace: true });
277
- return await page.mainFrame()._expect("to.have.title", { expectedText, isNot, timeout });
278
- }, expected, options);
279
- }
280
- function toHaveURL(page, expected, options) {
281
- if (typeof expected === "function")
282
- return import_toHaveURL.toHaveURLWithPredicate.call(this, page, expected, options);
283
- const baseURL = page.context()._options.baseURL;
284
- expected = typeof expected === "string" ? (0, import_utils.constructURLBasedOnBaseURL)(baseURL, expected) : expected;
285
- return import_toMatchText.toMatchText.call(this, "toHaveURL", page, "Page", async (isNot, timeout) => {
286
- const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase });
287
- return await page.mainFrame()._expect("to.have.url", { expectedText, isNot, timeout });
288
- }, expected, options);
289
- }
290
- async function toBeOK(response) {
291
- const matcherName = "toBeOK";
292
- (0, import_util.expectTypes)(response, ["APIResponse"], matcherName);
293
- const contentType = response.headers()["content-type"];
294
- const isTextEncoding = contentType && (0, import_utils.isTextualMimeType)(contentType);
295
- const [log, text] = this.isNot === response.ok() ? await Promise.all([
296
- response._fetchLog(),
297
- isTextEncoding ? response.text() : null
298
- ]) : [];
299
- const message = () => (0, import_utils.formatMatcherMessage)(this.utils, {
300
- isNot: this.isNot,
301
- promise: this.promise,
302
- matcherName,
303
- receiver: "response",
304
- expectation: "",
305
- log
306
- }) + (text === null ? "" : `
307
- Response text:
308
- ${import_utils2.colors.dim(text?.substring(0, 1e3) || "")}`);
309
- const pass = response.ok();
310
- return { message, pass };
311
- }
312
- async function toPass(callback, options = {}) {
313
- const testInfo = (0, import_globals.currentTestInfo)();
314
- const timeout = (0, import_config.takeFirst)(options.timeout, testInfo?._projectInternal.expect?.toPass?.timeout, 0);
315
- const intervals = (0, import_config.takeFirst)(options.intervals, testInfo?._projectInternal.expect?.toPass?.intervals, [100, 250, 500, 1e3]);
316
- const { deadline, timeoutMessage } = testInfo ? testInfo._deadlineForMatcher(timeout) : import_testInfo.TestInfoImpl._defaultDeadlineForMatcher(timeout);
317
- const result = await (0, import_utils.pollAgainstDeadline)(async () => {
318
- if (testInfo && (0, import_globals.currentTestInfo)() !== testInfo)
319
- return { continuePolling: false, result: void 0 };
320
- try {
321
- await callback();
322
- return { continuePolling: !!this.isNot, result: void 0 };
323
- } catch (e) {
324
- return { continuePolling: !this.isNot, result: e };
325
- }
326
- }, deadline, intervals);
327
- if (result.timedOut) {
328
- const message = result.result ? [
329
- result.result.message,
330
- "",
331
- `Call Log:`,
332
- `- ${timeoutMessage}`
333
- ].join("\n") : timeoutMessage;
334
- return { message: () => message, pass: !!this.isNot };
335
- }
336
- return { pass: !this.isNot, message: () => "" };
337
- }
338
- function computeMatcherTitleSuffix(matcherName, receiver, args) {
339
- if (matcherName === "toHaveScreenshot") {
340
- const title = (0, import_toMatchSnapshot.toHaveScreenshotStepTitle)(...args);
341
- return { short: title ? `(${title})` : "" };
342
- }
343
- if (receiver && typeof receiver === "object" && receiver.constructor?.name === "Locator") {
344
- try {
345
- return { long: " " + (0, import_utils.asLocatorDescription)("javascript", receiver._selector) };
346
- } catch {
347
- }
348
- }
349
- return {};
350
- }
351
- // Annotate the CommonJS export names for ESM import in node:
352
- 0 && (module.exports = {
353
- computeMatcherTitleSuffix,
354
- toBeAttached,
355
- toBeChecked,
356
- toBeDisabled,
357
- toBeEditable,
358
- toBeEmpty,
359
- toBeEnabled,
360
- toBeFocused,
361
- toBeHidden,
362
- toBeInViewport,
363
- toBeOK,
364
- toBeVisible,
365
- toContainClass,
366
- toContainText,
367
- toHaveAccessibleDescription,
368
- toHaveAccessibleErrorMessage,
369
- toHaveAccessibleName,
370
- toHaveAttribute,
371
- toHaveCSS,
372
- toHaveClass,
373
- toHaveCount,
374
- toHaveId,
375
- toHaveJSProperty,
376
- toHaveRole,
377
- toHaveText,
378
- toHaveTitle,
379
- toHaveURL,
380
- toHaveValue,
381
- toHaveValues,
382
- toPass
383
- });
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 matchers_exports = {};
20
+ __export(matchers_exports, {
21
+ computeMatcherTitleSuffix: () => computeMatcherTitleSuffix,
22
+ toBeAttached: () => toBeAttached,
23
+ toBeChecked: () => toBeChecked,
24
+ toBeDisabled: () => toBeDisabled,
25
+ toBeEditable: () => toBeEditable,
26
+ toBeEmpty: () => toBeEmpty,
27
+ toBeEnabled: () => toBeEnabled,
28
+ toBeFocused: () => toBeFocused,
29
+ toBeHidden: () => toBeHidden,
30
+ toBeInViewport: () => toBeInViewport,
31
+ toBeOK: () => toBeOK,
32
+ toBeVisible: () => toBeVisible,
33
+ toContainClass: () => toContainClass,
34
+ toContainText: () => toContainText,
35
+ toHaveAccessibleDescription: () => toHaveAccessibleDescription,
36
+ toHaveAccessibleErrorMessage: () => toHaveAccessibleErrorMessage,
37
+ toHaveAccessibleName: () => toHaveAccessibleName,
38
+ toHaveAttribute: () => toHaveAttribute,
39
+ toHaveCSS: () => toHaveCSS,
40
+ toHaveClass: () => toHaveClass,
41
+ toHaveCount: () => toHaveCount,
42
+ toHaveId: () => toHaveId,
43
+ toHaveJSProperty: () => toHaveJSProperty,
44
+ toHaveRole: () => toHaveRole,
45
+ toHaveText: () => toHaveText,
46
+ toHaveTitle: () => toHaveTitle,
47
+ toHaveURL: () => toHaveURL,
48
+ toHaveValue: () => toHaveValue,
49
+ toHaveValues: () => toHaveValues,
50
+ toPass: () => toPass
51
+ });
52
+ module.exports = __toCommonJS(matchers_exports);
53
+ var import_utils = require("patchright-bun-core/lib/utils");
54
+ var import_utils2 = require("patchright-bun-core/lib/utils");
55
+ var import_util = require("../util");
56
+ var import_toBeTruthy = require("./toBeTruthy");
57
+ var import_toEqual = require("./toEqual");
58
+ var import_toHaveURL = require("./toHaveURL");
59
+ var import_toMatchText = require("./toMatchText");
60
+ var import_toMatchSnapshot = require("./toMatchSnapshot");
61
+ var import_config = require("../common/config");
62
+ var import_globals = require("../common/globals");
63
+ var import_testInfo = require("../worker/testInfo");
64
+ function toBeAttached(locator, options) {
65
+ const attached = !options || options.attached === void 0 || options.attached;
66
+ const expected = attached ? "attached" : "detached";
67
+ const arg = attached ? "" : "{ attached: false }";
68
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeAttached", locator, "Locator", expected, arg, async (isNot, timeout) => {
69
+ return await locator._expect(attached ? "to.be.attached" : "to.be.detached", { isNot, timeout });
70
+ }, options);
71
+ }
72
+ function toBeChecked(locator, options) {
73
+ const checked = options?.checked;
74
+ const indeterminate = options?.indeterminate;
75
+ const expectedValue = {
76
+ checked,
77
+ indeterminate
78
+ };
79
+ let expected;
80
+ let arg;
81
+ if (options?.indeterminate) {
82
+ expected = "indeterminate";
83
+ arg = `{ indeterminate: true }`;
84
+ } else {
85
+ expected = options?.checked === false ? "unchecked" : "checked";
86
+ arg = options?.checked === false ? `{ checked: false }` : "";
87
+ }
88
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeChecked", locator, "Locator", expected, arg, async (isNot, timeout) => {
89
+ return await locator._expect("to.be.checked", { isNot, timeout, expectedValue });
90
+ }, options);
91
+ }
92
+ function toBeDisabled(locator, options) {
93
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeDisabled", locator, "Locator", "disabled", "", async (isNot, timeout) => {
94
+ return await locator._expect("to.be.disabled", { isNot, timeout });
95
+ }, options);
96
+ }
97
+ function toBeEditable(locator, options) {
98
+ const editable = !options || options.editable === void 0 || options.editable;
99
+ const expected = editable ? "editable" : "readOnly";
100
+ const arg = editable ? "" : "{ editable: false }";
101
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeEditable", locator, "Locator", expected, arg, async (isNot, timeout) => {
102
+ return await locator._expect(editable ? "to.be.editable" : "to.be.readonly", { isNot, timeout });
103
+ }, options);
104
+ }
105
+ function toBeEmpty(locator, options) {
106
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeEmpty", locator, "Locator", "empty", "", async (isNot, timeout) => {
107
+ return await locator._expect("to.be.empty", { isNot, timeout });
108
+ }, options);
109
+ }
110
+ function toBeEnabled(locator, options) {
111
+ const enabled = !options || options.enabled === void 0 || options.enabled;
112
+ const expected = enabled ? "enabled" : "disabled";
113
+ const arg = enabled ? "" : "{ enabled: false }";
114
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeEnabled", locator, "Locator", expected, arg, async (isNot, timeout) => {
115
+ return await locator._expect(enabled ? "to.be.enabled" : "to.be.disabled", { isNot, timeout });
116
+ }, options);
117
+ }
118
+ function toBeFocused(locator, options) {
119
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeFocused", locator, "Locator", "focused", "", async (isNot, timeout) => {
120
+ return await locator._expect("to.be.focused", { isNot, timeout });
121
+ }, options);
122
+ }
123
+ function toBeHidden(locator, options) {
124
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeHidden", locator, "Locator", "hidden", "", async (isNot, timeout) => {
125
+ return await locator._expect("to.be.hidden", { isNot, timeout });
126
+ }, options);
127
+ }
128
+ function toBeVisible(locator, options) {
129
+ const visible = !options || options.visible === void 0 || options.visible;
130
+ const expected = visible ? "visible" : "hidden";
131
+ const arg = visible ? "" : "{ visible: false }";
132
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeVisible", locator, "Locator", expected, arg, async (isNot, timeout) => {
133
+ return await locator._expect(visible ? "to.be.visible" : "to.be.hidden", { isNot, timeout });
134
+ }, options);
135
+ }
136
+ function toBeInViewport(locator, options) {
137
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeInViewport", locator, "Locator", "in viewport", "", async (isNot, timeout) => {
138
+ return await locator._expect("to.be.in.viewport", { isNot, expectedNumber: options?.ratio, timeout });
139
+ }, options);
140
+ }
141
+ function toContainText(locator, expected, options = {}) {
142
+ if (Array.isArray(expected)) {
143
+ return import_toEqual.toEqual.call(this, "toContainText", locator, "Locator", async (isNot, timeout) => {
144
+ const expectedText = (0, import_utils.serializeExpectedTextValues)(expected, { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
145
+ return await locator._expect("to.contain.text.array", { expectedText, isNot, useInnerText: options.useInnerText, timeout });
146
+ }, expected, { ...options, contains: true });
147
+ } else {
148
+ return import_toMatchText.toMatchText.call(this, "toContainText", locator, "Locator", async (isNot, timeout) => {
149
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
150
+ return await locator._expect("to.have.text", { expectedText, isNot, useInnerText: options.useInnerText, timeout });
151
+ }, expected, { ...options, matchSubstring: true });
152
+ }
153
+ }
154
+ function toHaveAccessibleDescription(locator, expected, options) {
155
+ return import_toMatchText.toMatchText.call(this, "toHaveAccessibleDescription", locator, "Locator", async (isNot, timeout) => {
156
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
157
+ return await locator._expect("to.have.accessible.description", { expectedText, isNot, timeout });
158
+ }, expected, options);
159
+ }
160
+ function toHaveAccessibleName(locator, expected, options) {
161
+ return import_toMatchText.toMatchText.call(this, "toHaveAccessibleName", locator, "Locator", async (isNot, timeout) => {
162
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
163
+ return await locator._expect("to.have.accessible.name", { expectedText, isNot, timeout });
164
+ }, expected, options);
165
+ }
166
+ function toHaveAccessibleErrorMessage(locator, expected, options) {
167
+ return import_toMatchText.toMatchText.call(this, "toHaveAccessibleErrorMessage", locator, "Locator", async (isNot, timeout) => {
168
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
169
+ return await locator._expect("to.have.accessible.error.message", { expectedText, isNot, timeout });
170
+ }, expected, options);
171
+ }
172
+ function toHaveAttribute(locator, name, expected, options) {
173
+ if (!options) {
174
+ if (typeof expected === "object" && !(0, import_utils.isRegExp)(expected)) {
175
+ options = expected;
176
+ expected = void 0;
177
+ }
178
+ }
179
+ if (expected === void 0) {
180
+ return import_toBeTruthy.toBeTruthy.call(this, "toHaveAttribute", locator, "Locator", "have attribute", "", async (isNot, timeout) => {
181
+ return await locator._expect("to.have.attribute", { expressionArg: name, isNot, timeout });
182
+ }, options);
183
+ }
184
+ return import_toMatchText.toMatchText.call(this, "toHaveAttribute", locator, "Locator", async (isNot, timeout) => {
185
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase });
186
+ return await locator._expect("to.have.attribute.value", { expressionArg: name, expectedText, isNot, timeout });
187
+ }, expected, options);
188
+ }
189
+ function toHaveClass(locator, expected, options) {
190
+ if (Array.isArray(expected)) {
191
+ return import_toEqual.toEqual.call(this, "toHaveClass", locator, "Locator", async (isNot, timeout) => {
192
+ const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
193
+ return await locator._expect("to.have.class.array", { expectedText, isNot, timeout });
194
+ }, expected, options);
195
+ } else {
196
+ return import_toMatchText.toMatchText.call(this, "toHaveClass", locator, "Locator", async (isNot, timeout) => {
197
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
198
+ return await locator._expect("to.have.class", { expectedText, isNot, timeout });
199
+ }, expected, options);
200
+ }
201
+ }
202
+ function toContainClass(locator, expected, options) {
203
+ if (Array.isArray(expected)) {
204
+ if (expected.some((e) => (0, import_utils.isRegExp)(e)))
205
+ throw new Error(`"expected" argument in toContainClass cannot contain RegExp values`);
206
+ return import_toEqual.toEqual.call(this, "toContainClass", locator, "Locator", async (isNot, timeout) => {
207
+ const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
208
+ return await locator._expect("to.contain.class.array", { expectedText, isNot, timeout });
209
+ }, expected, options);
210
+ } else {
211
+ if ((0, import_utils.isRegExp)(expected))
212
+ throw new Error(`"expected" argument in toContainClass cannot be a RegExp value`);
213
+ return import_toMatchText.toMatchText.call(this, "toContainClass", locator, "Locator", async (isNot, timeout) => {
214
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
215
+ return await locator._expect("to.contain.class", { expectedText, isNot, timeout });
216
+ }, expected, options);
217
+ }
218
+ }
219
+ function toHaveCount(locator, expected, options) {
220
+ return import_toEqual.toEqual.call(this, "toHaveCount", locator, "Locator", async (isNot, timeout) => {
221
+ return await locator._expect("to.have.count", { expectedNumber: expected, isNot, timeout });
222
+ }, expected, options);
223
+ }
224
+ function toHaveCSS(locator, name, expected, options) {
225
+ return import_toMatchText.toMatchText.call(this, "toHaveCSS", locator, "Locator", async (isNot, timeout) => {
226
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
227
+ return await locator._expect("to.have.css", { expressionArg: name, expectedText, isNot, timeout });
228
+ }, expected, options);
229
+ }
230
+ function toHaveId(locator, expected, options) {
231
+ return import_toMatchText.toMatchText.call(this, "toHaveId", locator, "Locator", async (isNot, timeout) => {
232
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
233
+ return await locator._expect("to.have.id", { expectedText, isNot, timeout });
234
+ }, expected, options);
235
+ }
236
+ function toHaveJSProperty(locator, name, expected, options) {
237
+ return import_toEqual.toEqual.call(this, "toHaveJSProperty", locator, "Locator", async (isNot, timeout) => {
238
+ return await locator._expect("to.have.property", { expressionArg: name, expectedValue: expected, isNot, timeout });
239
+ }, expected, options);
240
+ }
241
+ function toHaveRole(locator, expected, options) {
242
+ if (!(0, import_utils.isString)(expected))
243
+ throw new Error(`"role" argument in toHaveRole must be a string`);
244
+ return import_toMatchText.toMatchText.call(this, "toHaveRole", locator, "Locator", async (isNot, timeout) => {
245
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
246
+ return await locator._expect("to.have.role", { expectedText, isNot, timeout });
247
+ }, expected, options);
248
+ }
249
+ function toHaveText(locator, expected, options = {}) {
250
+ if (Array.isArray(expected)) {
251
+ return import_toEqual.toEqual.call(this, "toHaveText", locator, "Locator", async (isNot, timeout) => {
252
+ const expectedText = (0, import_utils.serializeExpectedTextValues)(expected, { normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
253
+ return await locator._expect("to.have.text.array", { expectedText, isNot, useInnerText: options?.useInnerText, timeout });
254
+ }, expected, options);
255
+ } else {
256
+ return import_toMatchText.toMatchText.call(this, "toHaveText", locator, "Locator", async (isNot, timeout) => {
257
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
258
+ return await locator._expect("to.have.text", { expectedText, isNot, useInnerText: options?.useInnerText, timeout });
259
+ }, expected, options);
260
+ }
261
+ }
262
+ function toHaveValue(locator, expected, options) {
263
+ return import_toMatchText.toMatchText.call(this, "toHaveValue", locator, "Locator", async (isNot, timeout) => {
264
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
265
+ return await locator._expect("to.have.value", { expectedText, isNot, timeout });
266
+ }, expected, options);
267
+ }
268
+ function toHaveValues(locator, expected, options) {
269
+ return import_toEqual.toEqual.call(this, "toHaveValues", locator, "Locator", async (isNot, timeout) => {
270
+ const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
271
+ return await locator._expect("to.have.values", { expectedText, isNot, timeout });
272
+ }, expected, options);
273
+ }
274
+ function toHaveTitle(page, expected, options = {}) {
275
+ return import_toMatchText.toMatchText.call(this, "toHaveTitle", page, "Page", async (isNot, timeout) => {
276
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { normalizeWhiteSpace: true });
277
+ return await page.mainFrame()._expect("to.have.title", { expectedText, isNot, timeout });
278
+ }, expected, options);
279
+ }
280
+ function toHaveURL(page, expected, options) {
281
+ if ((0, import_utils.isURLPattern)(expected))
282
+ return import_toHaveURL.toHaveURLWithPredicate.call(this, page, (url) => expected.test(url.href), options);
283
+ if (typeof expected === "function")
284
+ return import_toHaveURL.toHaveURLWithPredicate.call(this, page, expected, options);
285
+ const baseURL = page.context()._options.baseURL;
286
+ expected = typeof expected === "string" ? (0, import_utils.constructURLBasedOnBaseURL)(baseURL, expected) : expected;
287
+ return import_toMatchText.toMatchText.call(this, "toHaveURL", page, "Page", async (isNot, timeout) => {
288
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase });
289
+ return await page.mainFrame()._expect("to.have.url", { expectedText, isNot, timeout });
290
+ }, expected, options);
291
+ }
292
+ async function toBeOK(response) {
293
+ const matcherName = "toBeOK";
294
+ (0, import_util.expectTypes)(response, ["APIResponse"], matcherName);
295
+ const contentType = response.headers()["content-type"];
296
+ const isTextEncoding = contentType && (0, import_utils.isTextualMimeType)(contentType);
297
+ const [log, text] = this.isNot === response.ok() ? await Promise.all([
298
+ response._fetchLog(),
299
+ isTextEncoding ? response.text() : null
300
+ ]) : [];
301
+ const message = () => (0, import_utils.formatMatcherMessage)(this.utils, {
302
+ isNot: this.isNot,
303
+ promise: this.promise,
304
+ matcherName,
305
+ receiver: "response",
306
+ expectation: "",
307
+ log
308
+ }) + (text === null ? "" : `
309
+ Response text:
310
+ ${import_utils2.colors.dim(text?.substring(0, 1e3) || "")}`);
311
+ const pass = response.ok();
312
+ return { message, pass };
313
+ }
314
+ async function toPass(callback, options = {}) {
315
+ const testInfo = (0, import_globals.currentTestInfo)();
316
+ const timeout = (0, import_config.takeFirst)(options.timeout, testInfo?._projectInternal.expect?.toPass?.timeout, 0);
317
+ const intervals = (0, import_config.takeFirst)(options.intervals, testInfo?._projectInternal.expect?.toPass?.intervals, [100, 250, 500, 1e3]);
318
+ const { deadline, timeoutMessage } = testInfo ? testInfo._deadlineForMatcher(timeout) : import_testInfo.TestInfoImpl._defaultDeadlineForMatcher(timeout);
319
+ const result = await (0, import_utils.pollAgainstDeadline)(async () => {
320
+ if (testInfo && (0, import_globals.currentTestInfo)() !== testInfo)
321
+ return { continuePolling: false, result: void 0 };
322
+ try {
323
+ await callback();
324
+ return { continuePolling: !!this.isNot, result: void 0 };
325
+ } catch (e) {
326
+ return { continuePolling: !this.isNot, result: e };
327
+ }
328
+ }, deadline, intervals);
329
+ if (result.timedOut) {
330
+ const message = result.result ? [
331
+ result.result.message,
332
+ "",
333
+ `Call Log:`,
334
+ `- ${timeoutMessage}`
335
+ ].join("\n") : timeoutMessage;
336
+ return { message: () => message, pass: !!this.isNot };
337
+ }
338
+ return { pass: !this.isNot, message: () => "" };
339
+ }
340
+ function computeMatcherTitleSuffix(matcherName, receiver, args) {
341
+ if (matcherName === "toHaveScreenshot") {
342
+ const title = (0, import_toMatchSnapshot.toHaveScreenshotStepTitle)(...args);
343
+ return { short: title ? `(${title})` : "" };
344
+ }
345
+ if (receiver && typeof receiver === "object" && receiver.constructor?.name === "Locator") {
346
+ try {
347
+ return { long: " " + (0, import_utils.asLocatorDescription)("javascript", receiver._selector) };
348
+ } catch {
349
+ }
350
+ }
351
+ return {};
352
+ }
353
+ // Annotate the CommonJS export names for ESM import in node:
354
+ 0 && (module.exports = {
355
+ computeMatcherTitleSuffix,
356
+ toBeAttached,
357
+ toBeChecked,
358
+ toBeDisabled,
359
+ toBeEditable,
360
+ toBeEmpty,
361
+ toBeEnabled,
362
+ toBeFocused,
363
+ toBeHidden,
364
+ toBeInViewport,
365
+ toBeOK,
366
+ toBeVisible,
367
+ toContainClass,
368
+ toContainText,
369
+ toHaveAccessibleDescription,
370
+ toHaveAccessibleErrorMessage,
371
+ toHaveAccessibleName,
372
+ toHaveAttribute,
373
+ toHaveCSS,
374
+ toHaveClass,
375
+ toHaveCount,
376
+ toHaveId,
377
+ toHaveJSProperty,
378
+ toHaveRole,
379
+ toHaveText,
380
+ toHaveTitle,
381
+ toHaveURL,
382
+ toHaveValue,
383
+ toHaveValues,
384
+ toPass
385
+ });