@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,258 @@
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 fixtureRunner_exports = {};
20
+ __export(fixtureRunner_exports, {
21
+ FixtureRunner: () => FixtureRunner
22
+ });
23
+ module.exports = __toCommonJS(fixtureRunner_exports);
24
+ var import_utils = require("playwright-core/lib/utils");
25
+ var import_fixtures = require("../common/fixtures");
26
+ var import_util = require("../util");
27
+ class Fixture {
28
+ constructor(runner, registration) {
29
+ this.failed = false;
30
+ this._deps = /* @__PURE__ */ new Set();
31
+ this._usages = /* @__PURE__ */ new Set();
32
+ this.runner = runner;
33
+ this.registration = registration;
34
+ this.value = null;
35
+ const isUserFixture = this.registration.location && (0, import_util.filterStackFile)(this.registration.location.file);
36
+ const title = this.registration.customTitle || this.registration.name;
37
+ const location = isUserFixture ? this.registration.location : void 0;
38
+ this._stepInfo = { title: `Fixture ${(0, import_utils.escapeWithQuotes)(title, '"')}`, category: "fixture", location };
39
+ if (this.registration.box === "self")
40
+ this._stepInfo = void 0;
41
+ else if (this.registration.box)
42
+ this._stepInfo.group = isUserFixture ? "configuration" : "internal";
43
+ this._setupDescription = {
44
+ title,
45
+ phase: "setup",
46
+ location,
47
+ slot: this.registration.timeout === void 0 ? void 0 : {
48
+ timeout: this.registration.timeout,
49
+ elapsed: 0
50
+ }
51
+ };
52
+ this._teardownDescription = { ...this._setupDescription, phase: "teardown" };
53
+ }
54
+ async setup(testInfo, runnable) {
55
+ this.runner.instanceForId.set(this.registration.id, this);
56
+ if (typeof this.registration.fn !== "function") {
57
+ this.value = this.registration.fn;
58
+ return;
59
+ }
60
+ const run = () => testInfo._runWithTimeout({ ...runnable, fixture: this._setupDescription }, () => this._setupInternal(testInfo));
61
+ if (this._stepInfo)
62
+ await testInfo._runAsStep(this._stepInfo, run);
63
+ else
64
+ await run();
65
+ }
66
+ async _setupInternal(testInfo) {
67
+ const params = {};
68
+ for (const name of this.registration.deps) {
69
+ const registration = this.runner.pool.resolve(name, this.registration);
70
+ const dep = this.runner.instanceForId.get(registration.id);
71
+ if (!dep) {
72
+ this.failed = true;
73
+ return;
74
+ }
75
+ dep._usages.add(this);
76
+ this._deps.add(dep);
77
+ params[name] = dep.value;
78
+ if (dep.failed) {
79
+ this.failed = true;
80
+ return;
81
+ }
82
+ }
83
+ let called = false;
84
+ const useFuncStarted = new import_utils.ManualPromise();
85
+ const useFunc = async (value) => {
86
+ if (called)
87
+ throw new Error(`Cannot provide fixture value for the second time`);
88
+ called = true;
89
+ this.value = value;
90
+ this._useFuncFinished = new import_utils.ManualPromise();
91
+ useFuncStarted.resolve();
92
+ await this._useFuncFinished;
93
+ };
94
+ const workerInfo = { config: testInfo.config, parallelIndex: testInfo.parallelIndex, workerIndex: testInfo.workerIndex, project: testInfo.project };
95
+ const info = this.registration.scope === "worker" ? workerInfo : testInfo;
96
+ this._selfTeardownComplete = (async () => {
97
+ try {
98
+ await this.registration.fn(params, useFunc, info);
99
+ if (!useFuncStarted.isDone())
100
+ throw new Error(`use() was not called in fixture "${this.registration.name}"`);
101
+ } catch (error) {
102
+ this.failed = true;
103
+ if (!useFuncStarted.isDone())
104
+ useFuncStarted.reject(error);
105
+ else
106
+ throw error;
107
+ }
108
+ })();
109
+ await useFuncStarted;
110
+ }
111
+ async teardown(testInfo, runnable) {
112
+ try {
113
+ const fixtureRunnable = { ...runnable, fixture: this._teardownDescription };
114
+ if (!testInfo._timeoutManager.isTimeExhaustedFor(fixtureRunnable)) {
115
+ const run = () => testInfo._runWithTimeout(fixtureRunnable, () => this._teardownInternal());
116
+ if (this._stepInfo)
117
+ await testInfo._runAsStep(this._stepInfo, run);
118
+ else
119
+ await run();
120
+ }
121
+ } finally {
122
+ for (const dep of this._deps)
123
+ dep._usages.delete(this);
124
+ this.runner.instanceForId.delete(this.registration.id);
125
+ }
126
+ }
127
+ async _teardownInternal() {
128
+ if (typeof this.registration.fn !== "function")
129
+ return;
130
+ if (this._usages.size !== 0) {
131
+ console.error("Internal error: fixture integrity at", this._teardownDescription.title);
132
+ this._usages.clear();
133
+ }
134
+ if (this._useFuncFinished) {
135
+ this._useFuncFinished.resolve();
136
+ this._useFuncFinished = void 0;
137
+ await this._selfTeardownComplete;
138
+ }
139
+ }
140
+ _collectFixturesInTeardownOrder(scope, collector) {
141
+ if (this.registration.scope !== scope)
142
+ return;
143
+ for (const fixture of this._usages)
144
+ fixture._collectFixturesInTeardownOrder(scope, collector);
145
+ collector.add(this);
146
+ }
147
+ }
148
+ class FixtureRunner {
149
+ constructor() {
150
+ this.testScopeClean = true;
151
+ this.instanceForId = /* @__PURE__ */ new Map();
152
+ }
153
+ setPool(pool) {
154
+ if (!this.testScopeClean)
155
+ throw new Error("Did not teardown test scope");
156
+ if (this.pool && pool.digest !== this.pool.digest) {
157
+ throw new Error([
158
+ `Playwright detected inconsistent test.use() options.`,
159
+ `Most common mistakes that lead to this issue:`,
160
+ ` - Calling test.use() outside of the test file, for example in a common helper.`,
161
+ ` - One test file imports from another test file.`
162
+ ].join("\n"));
163
+ }
164
+ this.pool = pool;
165
+ }
166
+ _collectFixturesInSetupOrder(registration, collector) {
167
+ if (collector.has(registration))
168
+ return;
169
+ for (const name of registration.deps) {
170
+ const dep = this.pool.resolve(name, registration);
171
+ this._collectFixturesInSetupOrder(dep, collector);
172
+ }
173
+ collector.add(registration);
174
+ }
175
+ async teardownScope(scope, testInfo, runnable) {
176
+ const fixtures = Array.from(this.instanceForId.values()).reverse();
177
+ const collector = /* @__PURE__ */ new Set();
178
+ for (const fixture of fixtures)
179
+ fixture._collectFixturesInTeardownOrder(scope, collector);
180
+ let firstError;
181
+ for (const fixture of collector) {
182
+ try {
183
+ await fixture.teardown(testInfo, runnable);
184
+ } catch (error) {
185
+ firstError = firstError ?? error;
186
+ }
187
+ }
188
+ if (scope === "test")
189
+ this.testScopeClean = true;
190
+ if (firstError)
191
+ throw firstError;
192
+ }
193
+ async resolveParametersForFunction(fn, testInfo, autoFixtures, runnable) {
194
+ const collector = /* @__PURE__ */ new Set();
195
+ const auto = [];
196
+ for (const registration of this.pool.autoFixtures()) {
197
+ let shouldRun = true;
198
+ if (autoFixtures === "all-hooks-only")
199
+ shouldRun = registration.scope === "worker" || registration.auto === "all-hooks-included";
200
+ else if (autoFixtures === "worker")
201
+ shouldRun = registration.scope === "worker";
202
+ if (shouldRun)
203
+ auto.push(registration);
204
+ }
205
+ auto.sort((r1, r2) => (r1.scope === "worker" ? 0 : 1) - (r2.scope === "worker" ? 0 : 1));
206
+ for (const registration of auto)
207
+ this._collectFixturesInSetupOrder(registration, collector);
208
+ const names = getRequiredFixtureNames(fn);
209
+ for (const name of names)
210
+ this._collectFixturesInSetupOrder(this.pool.resolve(name), collector);
211
+ for (const registration of collector)
212
+ await this._setupFixtureForRegistration(registration, testInfo, runnable);
213
+ const params = {};
214
+ for (const name of names) {
215
+ const registration = this.pool.resolve(name);
216
+ const fixture = this.instanceForId.get(registration.id);
217
+ if (!fixture || fixture.failed)
218
+ return null;
219
+ params[name] = fixture.value;
220
+ }
221
+ return params;
222
+ }
223
+ async resolveParametersAndRunFunction(fn, testInfo, autoFixtures, runnable) {
224
+ const params = await this.resolveParametersForFunction(fn, testInfo, autoFixtures, runnable);
225
+ if (params === null) {
226
+ return null;
227
+ }
228
+ await testInfo._runWithTimeout(runnable, () => fn(params, testInfo));
229
+ }
230
+ async _setupFixtureForRegistration(registration, testInfo, runnable) {
231
+ if (registration.scope === "test")
232
+ this.testScopeClean = false;
233
+ let fixture = this.instanceForId.get(registration.id);
234
+ if (fixture)
235
+ return fixture;
236
+ fixture = new Fixture(this, registration);
237
+ await fixture.setup(testInfo, runnable);
238
+ return fixture;
239
+ }
240
+ dependsOnWorkerFixturesOnly(fn, location) {
241
+ const names = getRequiredFixtureNames(fn, location);
242
+ for (const name of names) {
243
+ const registration = this.pool.resolve(name);
244
+ if (registration.scope !== "worker")
245
+ return false;
246
+ }
247
+ return true;
248
+ }
249
+ }
250
+ function getRequiredFixtureNames(fn, location) {
251
+ return (0, import_fixtures.fixtureParameterNames)(fn, location ?? { file: "<unknown>", line: 1, column: 1 }, (e) => {
252
+ throw new Error(`${(0, import_util.formatLocation)(e.location)}: ${e.message}`);
253
+ });
254
+ }
255
+ // Annotate the CommonJS export names for ESM import in node:
256
+ 0 && (module.exports = {
257
+ FixtureRunner
258
+ });