@scoutqa/playwright 1.58.0-fork.1

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 (172) hide show
  1. package/ThirdPartyNotices.txt +3919 -0
  2. package/cli.js +19 -0
  3. package/index.d.ts +17 -0
  4. package/index.js +17 -0
  5. package/index.mjs +18 -0
  6. package/jsx-runtime.js +42 -0
  7. package/jsx-runtime.mjs +21 -0
  8. package/lib/agents/agentParser.js +89 -0
  9. package/lib/agents/copilot-setup-steps.yml +34 -0
  10. package/lib/agents/generateAgents.js +348 -0
  11. package/lib/agents/playwright-test-coverage.prompt.md +31 -0
  12. package/lib/agents/playwright-test-generate.prompt.md +8 -0
  13. package/lib/agents/playwright-test-generator.agent.md +88 -0
  14. package/lib/agents/playwright-test-heal.prompt.md +6 -0
  15. package/lib/agents/playwright-test-healer.agent.md +55 -0
  16. package/lib/agents/playwright-test-plan.prompt.md +9 -0
  17. package/lib/agents/playwright-test-planner.agent.md +73 -0
  18. package/lib/common/config.js +281 -0
  19. package/lib/common/configLoader.js +344 -0
  20. package/lib/common/esmLoaderHost.js +104 -0
  21. package/lib/common/expectBundle.js +43 -0
  22. package/lib/common/expectBundleImpl.js +407 -0
  23. package/lib/common/fixtures.js +302 -0
  24. package/lib/common/globals.js +58 -0
  25. package/lib/common/ipc.js +60 -0
  26. package/lib/common/poolBuilder.js +85 -0
  27. package/lib/common/process.js +132 -0
  28. package/lib/common/suiteUtils.js +140 -0
  29. package/lib/common/test.js +322 -0
  30. package/lib/common/testLoader.js +101 -0
  31. package/lib/common/testType.js +298 -0
  32. package/lib/common/validators.js +68 -0
  33. package/lib/fsWatcher.js +67 -0
  34. package/lib/index.js +721 -0
  35. package/lib/internalsForTest.js +42 -0
  36. package/lib/isomorphic/events.js +77 -0
  37. package/lib/isomorphic/folders.js +30 -0
  38. package/lib/isomorphic/stringInternPool.js +69 -0
  39. package/lib/isomorphic/teleReceiver.js +523 -0
  40. package/lib/isomorphic/teleSuiteUpdater.js +157 -0
  41. package/lib/isomorphic/testServerConnection.js +225 -0
  42. package/lib/isomorphic/testServerInterface.js +16 -0
  43. package/lib/isomorphic/testTree.js +329 -0
  44. package/lib/isomorphic/types.d.js +16 -0
  45. package/lib/loader/loaderMain.js +59 -0
  46. package/lib/matchers/expect.js +324 -0
  47. package/lib/matchers/matcherHint.js +87 -0
  48. package/lib/matchers/matchers.js +382 -0
  49. package/lib/matchers/toBeTruthy.js +73 -0
  50. package/lib/matchers/toEqual.js +99 -0
  51. package/lib/matchers/toHaveURL.js +102 -0
  52. package/lib/matchers/toMatchAriaSnapshot.js +159 -0
  53. package/lib/matchers/toMatchSnapshot.js +341 -0
  54. package/lib/matchers/toMatchText.js +99 -0
  55. package/lib/mcp/browser/actions.d.js +16 -0
  56. package/lib/mcp/browser/browserContextFactory.js +321 -0
  57. package/lib/mcp/browser/browserServerBackend.js +77 -0
  58. package/lib/mcp/browser/config.js +418 -0
  59. package/lib/mcp/browser/context.js +285 -0
  60. package/lib/mcp/browser/response.js +352 -0
  61. package/lib/mcp/browser/sessionLog.js +160 -0
  62. package/lib/mcp/browser/tab.js +328 -0
  63. package/lib/mcp/browser/tools/common.js +63 -0
  64. package/lib/mcp/browser/tools/console.js +44 -0
  65. package/lib/mcp/browser/tools/dialogs.js +60 -0
  66. package/lib/mcp/browser/tools/evaluate.js +59 -0
  67. package/lib/mcp/browser/tools/files.js +58 -0
  68. package/lib/mcp/browser/tools/form.js +63 -0
  69. package/lib/mcp/browser/tools/install.js +69 -0
  70. package/lib/mcp/browser/tools/keyboard.js +84 -0
  71. package/lib/mcp/browser/tools/mouse.js +107 -0
  72. package/lib/mcp/browser/tools/navigate.js +62 -0
  73. package/lib/mcp/browser/tools/network.js +60 -0
  74. package/lib/mcp/browser/tools/pdf.js +48 -0
  75. package/lib/mcp/browser/tools/runCode.js +77 -0
  76. package/lib/mcp/browser/tools/screenshot.js +105 -0
  77. package/lib/mcp/browser/tools/snapshot.js +191 -0
  78. package/lib/mcp/browser/tools/tabs.js +67 -0
  79. package/lib/mcp/browser/tools/tool.js +50 -0
  80. package/lib/mcp/browser/tools/tracing.js +74 -0
  81. package/lib/mcp/browser/tools/utils.js +94 -0
  82. package/lib/mcp/browser/tools/verify.js +143 -0
  83. package/lib/mcp/browser/tools/wait.js +63 -0
  84. package/lib/mcp/browser/tools.js +82 -0
  85. package/lib/mcp/browser/watchdog.js +44 -0
  86. package/lib/mcp/config.d.js +16 -0
  87. package/lib/mcp/extension/cdpRelay.js +351 -0
  88. package/lib/mcp/extension/extensionContextFactory.js +76 -0
  89. package/lib/mcp/extension/protocol.js +28 -0
  90. package/lib/mcp/index.js +61 -0
  91. package/lib/mcp/log.js +35 -0
  92. package/lib/mcp/program.js +93 -0
  93. package/lib/mcp/sdk/exports.js +28 -0
  94. package/lib/mcp/sdk/http.js +152 -0
  95. package/lib/mcp/sdk/inProcessTransport.js +71 -0
  96. package/lib/mcp/sdk/server.js +207 -0
  97. package/lib/mcp/sdk/tool.js +47 -0
  98. package/lib/mcp/test/browserBackend.js +98 -0
  99. package/lib/mcp/test/generatorTools.js +122 -0
  100. package/lib/mcp/test/plannerTools.js +144 -0
  101. package/lib/mcp/test/seed.js +82 -0
  102. package/lib/mcp/test/streams.js +44 -0
  103. package/lib/mcp/test/testBackend.js +99 -0
  104. package/lib/mcp/test/testContext.js +279 -0
  105. package/lib/mcp/test/testTool.js +30 -0
  106. package/lib/mcp/test/testTools.js +108 -0
  107. package/lib/plugins/gitCommitInfoPlugin.js +198 -0
  108. package/lib/plugins/index.js +28 -0
  109. package/lib/plugins/webServerPlugin.js +237 -0
  110. package/lib/program.js +417 -0
  111. package/lib/reporters/base.js +609 -0
  112. package/lib/reporters/blob.js +139 -0
  113. package/lib/reporters/dot.js +82 -0
  114. package/lib/reporters/empty.js +32 -0
  115. package/lib/reporters/github.js +128 -0
  116. package/lib/reporters/html.js +623 -0
  117. package/lib/reporters/internalReporter.js +140 -0
  118. package/lib/reporters/json.js +255 -0
  119. package/lib/reporters/junit.js +232 -0
  120. package/lib/reporters/line.js +113 -0
  121. package/lib/reporters/list.js +231 -0
  122. package/lib/reporters/listModeReporter.js +69 -0
  123. package/lib/reporters/markdown.js +144 -0
  124. package/lib/reporters/merge.js +546 -0
  125. package/lib/reporters/multiplexer.js +112 -0
  126. package/lib/reporters/reporterV2.js +102 -0
  127. package/lib/reporters/teleEmitter.js +319 -0
  128. package/lib/reporters/versions/blobV1.js +16 -0
  129. package/lib/runner/dispatcher.js +533 -0
  130. package/lib/runner/failureTracker.js +72 -0
  131. package/lib/runner/lastRun.js +77 -0
  132. package/lib/runner/loadUtils.js +334 -0
  133. package/lib/runner/loaderHost.js +89 -0
  134. package/lib/runner/processHost.js +180 -0
  135. package/lib/runner/projectUtils.js +241 -0
  136. package/lib/runner/rebase.js +189 -0
  137. package/lib/runner/reporters.js +138 -0
  138. package/lib/runner/sigIntWatcher.js +96 -0
  139. package/lib/runner/storage.js +91 -0
  140. package/lib/runner/taskRunner.js +127 -0
  141. package/lib/runner/tasks.js +410 -0
  142. package/lib/runner/testGroups.js +125 -0
  143. package/lib/runner/testRunner.js +398 -0
  144. package/lib/runner/testServer.js +269 -0
  145. package/lib/runner/uiModeReporter.js +30 -0
  146. package/lib/runner/vcs.js +72 -0
  147. package/lib/runner/watchMode.js +396 -0
  148. package/lib/runner/workerHost.js +104 -0
  149. package/lib/third_party/pirates.js +62 -0
  150. package/lib/third_party/tsconfig-loader.js +103 -0
  151. package/lib/transform/babelBundle.js +43 -0
  152. package/lib/transform/babelBundleImpl.js +461 -0
  153. package/lib/transform/babelHighlightUtils.js +63 -0
  154. package/lib/transform/compilationCache.js +272 -0
  155. package/lib/transform/esmLoader.js +103 -0
  156. package/lib/transform/portTransport.js +67 -0
  157. package/lib/transform/transform.js +296 -0
  158. package/lib/util.js +403 -0
  159. package/lib/utilsBundle.js +43 -0
  160. package/lib/utilsBundleImpl.js +100 -0
  161. package/lib/worker/fixtureRunner.js +258 -0
  162. package/lib/worker/testInfo.js +557 -0
  163. package/lib/worker/testTracing.js +345 -0
  164. package/lib/worker/timeoutManager.js +174 -0
  165. package/lib/worker/util.js +31 -0
  166. package/lib/worker/workerMain.js +529 -0
  167. package/package.json +72 -0
  168. package/test.d.ts +18 -0
  169. package/test.js +24 -0
  170. package/test.mjs +34 -0
  171. package/types/test.d.ts +10277 -0
  172. package/types/testReporter.d.ts +827 -0
@@ -0,0 +1,324 @@
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 expect_exports = {};
20
+ __export(expect_exports, {
21
+ expect: () => expect,
22
+ mergeExpects: () => mergeExpects,
23
+ printReceivedStringContainExpectedResult: () => printReceivedStringContainExpectedResult,
24
+ printReceivedStringContainExpectedSubstring: () => printReceivedStringContainExpectedSubstring
25
+ });
26
+ module.exports = __toCommonJS(expect_exports);
27
+ var import_utils = require("playwright-core/lib/utils");
28
+ var import_matcherHint = require("./matcherHint");
29
+ var import_matchers = require("./matchers");
30
+ var import_toMatchAriaSnapshot = require("./toMatchAriaSnapshot");
31
+ var import_toMatchSnapshot = require("./toMatchSnapshot");
32
+ var import_expectBundle = require("../common/expectBundle");
33
+ var import_globals = require("../common/globals");
34
+ var import_util = require("../util");
35
+ var import_testInfo = require("../worker/testInfo");
36
+ const printSubstring = (val) => val.replace(/"|\\/g, "\\$&");
37
+ const printReceivedStringContainExpectedSubstring = (received, start, length) => (0, import_expectBundle.RECEIVED_COLOR)(
38
+ '"' + printSubstring(received.slice(0, start)) + (0, import_expectBundle.INVERTED_COLOR)(printSubstring(received.slice(start, start + length))) + printSubstring(received.slice(start + length)) + '"'
39
+ );
40
+ const printReceivedStringContainExpectedResult = (received, result) => result === null ? (0, import_expectBundle.printReceived)(received) : printReceivedStringContainExpectedSubstring(
41
+ received,
42
+ result.index,
43
+ result[0].length
44
+ );
45
+ function createMatchers(actual, info, prefix) {
46
+ return new Proxy((0, import_expectBundle.expect)(actual), new ExpectMetaInfoProxyHandler(actual, info, prefix));
47
+ }
48
+ const userMatchersSymbol = Symbol("userMatchers");
49
+ function qualifiedMatcherName(qualifier, matcherName) {
50
+ return qualifier.join(":") + "$" + matcherName;
51
+ }
52
+ function createExpect(info, prefix, userMatchers) {
53
+ const expectInstance = new Proxy(import_expectBundle.expect, {
54
+ apply: function(target, thisArg, argumentsList) {
55
+ const [actual, messageOrOptions] = argumentsList;
56
+ const message = (0, import_utils.isString)(messageOrOptions) ? messageOrOptions : messageOrOptions?.message || info.message;
57
+ const newInfo = { ...info, message };
58
+ if (newInfo.poll) {
59
+ if (typeof actual !== "function")
60
+ throw new Error("`expect.poll()` accepts only function as a first argument");
61
+ newInfo.poll.generator = actual;
62
+ }
63
+ return createMatchers(actual, newInfo, prefix);
64
+ },
65
+ get: function(target, property) {
66
+ if (property === "configure")
67
+ return configure;
68
+ if (property === "extend") {
69
+ return (matchers) => {
70
+ const qualifier = [...prefix, (0, import_utils.createGuid)()];
71
+ const wrappedMatchers = {};
72
+ for (const [name, matcher] of Object.entries(matchers)) {
73
+ wrappedMatchers[name] = wrapPlaywrightMatcherToPassNiceThis(matcher);
74
+ const key = qualifiedMatcherName(qualifier, name);
75
+ wrappedMatchers[key] = wrappedMatchers[name];
76
+ Object.defineProperty(wrappedMatchers[key], "name", { value: name });
77
+ }
78
+ import_expectBundle.expect.extend(wrappedMatchers);
79
+ return createExpect(info, qualifier, { ...userMatchers, ...matchers });
80
+ };
81
+ }
82
+ if (property === "soft") {
83
+ return (actual, messageOrOptions) => {
84
+ return configure({ soft: true })(actual, messageOrOptions);
85
+ };
86
+ }
87
+ if (property === userMatchersSymbol)
88
+ return userMatchers;
89
+ if (property === "poll") {
90
+ return (actual, messageOrOptions) => {
91
+ const poll = (0, import_utils.isString)(messageOrOptions) ? {} : messageOrOptions || {};
92
+ return configure({ _poll: poll })(actual, messageOrOptions);
93
+ };
94
+ }
95
+ return import_expectBundle.expect[property];
96
+ }
97
+ });
98
+ const configure = (configuration) => {
99
+ const newInfo = { ...info };
100
+ if ("message" in configuration)
101
+ newInfo.message = configuration.message;
102
+ if ("timeout" in configuration)
103
+ newInfo.timeout = configuration.timeout;
104
+ if ("soft" in configuration)
105
+ newInfo.isSoft = configuration.soft;
106
+ if ("_poll" in configuration) {
107
+ newInfo.poll = configuration._poll ? { ...info.poll, generator: () => {
108
+ } } : void 0;
109
+ if (typeof configuration._poll === "object") {
110
+ newInfo.poll.timeout = configuration._poll.timeout ?? newInfo.poll.timeout;
111
+ newInfo.poll.intervals = configuration._poll.intervals ?? newInfo.poll.intervals;
112
+ }
113
+ }
114
+ return createExpect(newInfo, prefix, userMatchers);
115
+ };
116
+ return expectInstance;
117
+ }
118
+ let matcherCallContext;
119
+ function setMatcherCallContext(context) {
120
+ matcherCallContext = context;
121
+ }
122
+ function takeMatcherCallContext() {
123
+ try {
124
+ return matcherCallContext;
125
+ } finally {
126
+ matcherCallContext = void 0;
127
+ }
128
+ }
129
+ const defaultExpectTimeout = 5e3;
130
+ function wrapPlaywrightMatcherToPassNiceThis(matcher) {
131
+ return function(...args) {
132
+ const { isNot, promise, utils } = this;
133
+ const context = takeMatcherCallContext();
134
+ const timeout = context?.expectInfo.timeout ?? context?.testInfo?._projectInternal?.expect?.timeout ?? defaultExpectTimeout;
135
+ const newThis = {
136
+ isNot,
137
+ promise,
138
+ utils,
139
+ timeout,
140
+ _stepInfo: context?.step
141
+ };
142
+ newThis.equals = throwUnsupportedExpectMatcherError;
143
+ return matcher.call(newThis, ...args);
144
+ };
145
+ }
146
+ function throwUnsupportedExpectMatcherError() {
147
+ throw new Error("It looks like you are using custom expect matchers that are not compatible with Playwright. See https://aka.ms/playwright/expect-compatibility");
148
+ }
149
+ import_expectBundle.expect.setState({ expand: false });
150
+ const customAsyncMatchers = {
151
+ toBeAttached: import_matchers.toBeAttached,
152
+ toBeChecked: import_matchers.toBeChecked,
153
+ toBeDisabled: import_matchers.toBeDisabled,
154
+ toBeEditable: import_matchers.toBeEditable,
155
+ toBeEmpty: import_matchers.toBeEmpty,
156
+ toBeEnabled: import_matchers.toBeEnabled,
157
+ toBeFocused: import_matchers.toBeFocused,
158
+ toBeHidden: import_matchers.toBeHidden,
159
+ toBeInViewport: import_matchers.toBeInViewport,
160
+ toBeOK: import_matchers.toBeOK,
161
+ toBeVisible: import_matchers.toBeVisible,
162
+ toContainText: import_matchers.toContainText,
163
+ toContainClass: import_matchers.toContainClass,
164
+ toHaveAccessibleDescription: import_matchers.toHaveAccessibleDescription,
165
+ toHaveAccessibleName: import_matchers.toHaveAccessibleName,
166
+ toHaveAccessibleErrorMessage: import_matchers.toHaveAccessibleErrorMessage,
167
+ toHaveAttribute: import_matchers.toHaveAttribute,
168
+ toHaveClass: import_matchers.toHaveClass,
169
+ toHaveCount: import_matchers.toHaveCount,
170
+ toHaveCSS: import_matchers.toHaveCSS,
171
+ toHaveId: import_matchers.toHaveId,
172
+ toHaveJSProperty: import_matchers.toHaveJSProperty,
173
+ toHaveRole: import_matchers.toHaveRole,
174
+ toHaveText: import_matchers.toHaveText,
175
+ toHaveTitle: import_matchers.toHaveTitle,
176
+ toHaveURL: import_matchers.toHaveURL,
177
+ toHaveValue: import_matchers.toHaveValue,
178
+ toHaveValues: import_matchers.toHaveValues,
179
+ toHaveScreenshot: import_toMatchSnapshot.toHaveScreenshot,
180
+ toMatchAriaSnapshot: import_toMatchAriaSnapshot.toMatchAriaSnapshot,
181
+ toPass: import_matchers.toPass
182
+ };
183
+ const customMatchers = {
184
+ ...customAsyncMatchers,
185
+ toMatchSnapshot: import_toMatchSnapshot.toMatchSnapshot
186
+ };
187
+ class ExpectMetaInfoProxyHandler {
188
+ constructor(actual, info, prefix) {
189
+ this._actual = actual;
190
+ this._info = { ...info };
191
+ this._prefix = prefix;
192
+ }
193
+ get(target, matcherName, receiver) {
194
+ if (matcherName === "toThrowError")
195
+ matcherName = "toThrow";
196
+ let matcher = Reflect.get(target, matcherName, receiver);
197
+ if (typeof matcherName !== "string")
198
+ return matcher;
199
+ let resolvedMatcherName = matcherName;
200
+ for (let i = this._prefix.length; i > 0; i--) {
201
+ const qualifiedName = qualifiedMatcherName(this._prefix.slice(0, i), matcherName);
202
+ if (Reflect.has(target, qualifiedName)) {
203
+ matcher = Reflect.get(target, qualifiedName, receiver);
204
+ resolvedMatcherName = qualifiedName;
205
+ break;
206
+ }
207
+ }
208
+ if (matcher === void 0)
209
+ throw new Error(`expect: Property '${matcherName}' not found.`);
210
+ if (typeof matcher !== "function") {
211
+ if (matcherName === "not")
212
+ this._info.isNot = !this._info.isNot;
213
+ return new Proxy(matcher, this);
214
+ }
215
+ if (this._info.poll) {
216
+ if (customAsyncMatchers[matcherName] || matcherName === "resolves" || matcherName === "rejects")
217
+ throw new Error(`\`expect.poll()\` does not support "${matcherName}" matcher.`);
218
+ matcher = (...args) => pollMatcher(resolvedMatcherName, this._info, this._prefix, ...args);
219
+ }
220
+ return (...args) => {
221
+ const testInfo = (0, import_globals.currentTestInfo)();
222
+ setMatcherCallContext({ expectInfo: this._info, testInfo });
223
+ if (!testInfo)
224
+ return matcher.call(target, ...args);
225
+ const customMessage = this._info.message || "";
226
+ const suffixes = (0, import_matchers.computeMatcherTitleSuffix)(matcherName, this._actual, args);
227
+ const defaultTitle = `${this._info.poll ? "poll " : ""}${this._info.isSoft ? "soft " : ""}${this._info.isNot ? "not " : ""}${matcherName}${suffixes.short || ""}`;
228
+ const shortTitle = customMessage || `Expect ${(0, import_utils.escapeWithQuotes)(defaultTitle, '"')}`;
229
+ const longTitle = shortTitle + (suffixes.long || "");
230
+ const apiName = `expect${this._info.poll ? ".poll " : ""}${this._info.isSoft ? ".soft " : ""}${this._info.isNot ? ".not" : ""}.${matcherName}${suffixes.short || ""}`;
231
+ const stackFrames = (0, import_util.filteredStackTrace)((0, import_utils.captureRawStack)());
232
+ const stepInfo = {
233
+ category: "expect",
234
+ apiName,
235
+ title: longTitle,
236
+ shortTitle,
237
+ params: args[0] ? { expected: args[0] } : void 0,
238
+ infectParentStepsWithError: this._info.isSoft
239
+ };
240
+ const step = testInfo._addStep(stepInfo);
241
+ const reportStepError = (e) => {
242
+ const jestError = (0, import_matcherHint.isJestError)(e) ? e : null;
243
+ const expectError = jestError ? new import_matcherHint.ExpectError(jestError, customMessage, stackFrames) : void 0;
244
+ if (jestError?.matcherResult.suggestedRebaseline) {
245
+ step.complete({ suggestedRebaseline: jestError?.matcherResult.suggestedRebaseline });
246
+ return;
247
+ }
248
+ const error = expectError ?? e;
249
+ step.complete({ error });
250
+ if (this._info.isSoft)
251
+ testInfo._failWithError(error);
252
+ else
253
+ throw error;
254
+ };
255
+ const finalizer = () => {
256
+ step.complete({});
257
+ };
258
+ try {
259
+ setMatcherCallContext({ expectInfo: this._info, testInfo, step: step.info });
260
+ const callback = () => matcher.call(target, ...args);
261
+ const result = (0, import_utils.currentZone)().with("stepZone", step).run(callback);
262
+ if (result instanceof Promise)
263
+ return result.then(finalizer).catch(reportStepError);
264
+ finalizer();
265
+ return result;
266
+ } catch (e) {
267
+ void reportStepError(e);
268
+ }
269
+ };
270
+ }
271
+ }
272
+ async function pollMatcher(qualifiedMatcherName2, info, prefix, ...args) {
273
+ const testInfo = (0, import_globals.currentTestInfo)();
274
+ const poll = info.poll;
275
+ const timeout = poll.timeout ?? info.timeout ?? testInfo?._projectInternal?.expect?.timeout ?? defaultExpectTimeout;
276
+ const { deadline, timeoutMessage } = testInfo ? testInfo._deadlineForMatcher(timeout) : import_testInfo.TestInfoImpl._defaultDeadlineForMatcher(timeout);
277
+ const result = await (0, import_utils.pollAgainstDeadline)(async () => {
278
+ if (testInfo && (0, import_globals.currentTestInfo)() !== testInfo)
279
+ return { continuePolling: false, result: void 0 };
280
+ const innerInfo = {
281
+ ...info,
282
+ isSoft: false,
283
+ // soft is outside of poll, not inside
284
+ poll: void 0
285
+ };
286
+ const value = await poll.generator();
287
+ try {
288
+ let matchers = createMatchers(value, innerInfo, prefix);
289
+ if (info.isNot)
290
+ matchers = matchers.not;
291
+ matchers[qualifiedMatcherName2](...args);
292
+ return { continuePolling: false, result: void 0 };
293
+ } catch (error) {
294
+ return { continuePolling: true, result: error };
295
+ }
296
+ }, deadline, poll.intervals ?? [100, 250, 500, 1e3]);
297
+ if (result.timedOut) {
298
+ const message = result.result ? [
299
+ result.result.message,
300
+ "",
301
+ `Call Log:`,
302
+ `- ${timeoutMessage}`
303
+ ].join("\n") : timeoutMessage;
304
+ throw new Error(message);
305
+ }
306
+ }
307
+ const expect = createExpect({}, [], {}).extend(customMatchers);
308
+ function mergeExpects(...expects) {
309
+ let merged = expect;
310
+ for (const e of expects) {
311
+ const internals = e[userMatchersSymbol];
312
+ if (!internals)
313
+ continue;
314
+ merged = merged.extend(internals);
315
+ }
316
+ return merged;
317
+ }
318
+ // Annotate the CommonJS export names for ESM import in node:
319
+ 0 && (module.exports = {
320
+ expect,
321
+ mergeExpects,
322
+ printReceivedStringContainExpectedResult,
323
+ printReceivedStringContainExpectedSubstring
324
+ });
@@ -0,0 +1,87 @@
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 matcherHint_exports = {};
20
+ __export(matcherHint_exports, {
21
+ ExpectError: () => ExpectError,
22
+ callLogText: () => callLogText,
23
+ formatMatcherMessage: () => formatMatcherMessage,
24
+ isJestError: () => isJestError
25
+ });
26
+ module.exports = __toCommonJS(matcherHint_exports);
27
+ var import_utils = require("playwright-core/lib/utils");
28
+ var import_expectBundle = require("../common/expectBundle");
29
+ function formatMatcherMessage(state, details) {
30
+ const receiver = details.receiver ?? (details.locator ? "locator" : "page");
31
+ let message = (0, import_expectBundle.DIM_COLOR)("expect(") + (0, import_expectBundle.RECEIVED_COLOR)(receiver) + (0, import_expectBundle.DIM_COLOR)(")" + (state.promise ? "." + state.promise : "") + (state.isNot ? ".not" : "") + ".") + details.matcherName + (0, import_expectBundle.DIM_COLOR)("(") + (0, import_expectBundle.EXPECTED_COLOR)(details.expectation) + (0, import_expectBundle.DIM_COLOR)(")") + " failed\n\n";
32
+ const diffLines = details.printedDiff?.split("\n");
33
+ if (diffLines?.length === 2) {
34
+ details.printedExpected = diffLines[0];
35
+ details.printedReceived = diffLines[1];
36
+ details.printedDiff = void 0;
37
+ }
38
+ const align = !details.errorMessage && details.printedExpected?.startsWith("Expected:") && (!details.printedReceived || details.printedReceived.startsWith("Received:"));
39
+ if (details.locator)
40
+ message += `Locator: ${align ? " " : ""}${String(details.locator)}
41
+ `;
42
+ if (details.printedExpected)
43
+ message += details.printedExpected + "\n";
44
+ if (details.printedReceived)
45
+ message += details.printedReceived + "\n";
46
+ if (details.timedOut && details.timeout)
47
+ message += `Timeout: ${align ? " " : ""}${details.timeout}ms
48
+ `;
49
+ if (details.printedDiff)
50
+ message += details.printedDiff + "\n";
51
+ if (details.errorMessage) {
52
+ message += details.errorMessage;
53
+ if (!details.errorMessage.endsWith("\n"))
54
+ message += "\n";
55
+ }
56
+ message += callLogText(details.log);
57
+ return message;
58
+ }
59
+ class ExpectError extends Error {
60
+ constructor(jestError, customMessage, stackFrames) {
61
+ super("");
62
+ this.name = jestError.name;
63
+ this.message = jestError.message;
64
+ this.matcherResult = jestError.matcherResult;
65
+ if (customMessage)
66
+ this.message = customMessage + "\n\n" + this.message;
67
+ this.stack = this.name + ": " + this.message + "\n" + (0, import_utils.stringifyStackFrames)(stackFrames).join("\n");
68
+ }
69
+ }
70
+ function isJestError(e) {
71
+ return e instanceof Error && "matcherResult" in e && !!e.matcherResult;
72
+ }
73
+ const callLogText = (log) => {
74
+ if (!log || !log.some((l) => !!l))
75
+ return "";
76
+ return `
77
+ Call log:
78
+ ${(0, import_expectBundle.DIM_COLOR)(log.join("\n"))}
79
+ `;
80
+ };
81
+ // Annotate the CommonJS export names for ESM import in node:
82
+ 0 && (module.exports = {
83
+ ExpectError,
84
+ callLogText,
85
+ formatMatcherMessage,
86
+ isJestError
87
+ });