@smoothdeploy/playwright 1.58.3 → 1.60.0-beta-1780662356000

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 (182) hide show
  1. package/ThirdPartyNotices.txt +8 -5036
  2. package/lib/agents/agentParser.js +2 -2
  3. package/lib/agents/generateAgents.js +21 -22
  4. package/lib/agents/playwright-test-healer.agent.md +1 -0
  5. package/lib/agents/playwright-test-planner.agent.md +2 -1
  6. package/lib/cli/reportActions.js +78 -0
  7. package/lib/cli/testActions.js +211 -0
  8. package/lib/common/index.js +2898 -0
  9. package/lib/common/index.js.txt +35 -0
  10. package/lib/errorContext.js +130 -0
  11. package/lib/index.js +283 -206
  12. package/lib/{isomorphic/testServerConnection.js → isomorphic.js} +70 -35
  13. package/lib/isomorphic.js.txt +9 -0
  14. package/lib/loader/loaderProcessEntry.js +34 -0
  15. package/lib/loader/loaderProcessEntry.js.txt +9 -0
  16. package/lib/matchers/expect.js +12988 -249
  17. package/lib/matchers/expect.js.LICENSE +693 -0
  18. package/lib/matchers/expect.js.txt +72 -0
  19. package/lib/mcp/test/browserBackend.js +49 -22
  20. package/lib/mcp/test/generatorTools.js +16 -16
  21. package/lib/mcp/test/plannerTools.js +25 -20
  22. package/lib/mcp/test/seed.js +7 -7
  23. package/lib/mcp/test/testBackend.js +30 -30
  24. package/lib/mcp/test/testContext.js +50 -33
  25. package/lib/mcp/test/testTools.js +15 -25
  26. package/lib/{internalsForTest.js → package.js} +13 -8
  27. package/lib/program.js +63 -263
  28. package/lib/runner/index.js +8339 -0
  29. package/lib/runner/index.js.txt +60 -0
  30. package/lib/transform/babelBundle.js +71002 -18
  31. package/lib/transform/babelBundle.js.LICENSE +2359 -0
  32. package/lib/transform/babelBundle.js.txt +325 -0
  33. package/lib/transform/esmLoader.js +5884 -30
  34. package/lib/transform/esmLoader.js.LICENSE +335 -0
  35. package/lib/transform/esmLoader.js.txt +55 -0
  36. package/lib/util.js +37 -34
  37. package/lib/worker/workerProcessEntry.js +3251 -0
  38. package/lib/worker/workerProcessEntry.js.txt +24 -0
  39. package/package.json +5 -16
  40. package/test.mjs +1 -0
  41. package/types/test.d.ts +173 -12
  42. package/types/testReporter.d.ts +7 -5
  43. package/lib/common/config.js +0 -282
  44. package/lib/common/configLoader.js +0 -344
  45. package/lib/common/esmLoaderHost.js +0 -104
  46. package/lib/common/expectBundle.js +0 -28
  47. package/lib/common/expectBundleImpl.js +0 -407
  48. package/lib/common/fixtures.js +0 -302
  49. package/lib/common/ipc.js +0 -60
  50. package/lib/common/poolBuilder.js +0 -85
  51. package/lib/common/process.js +0 -132
  52. package/lib/common/suiteUtils.js +0 -140
  53. package/lib/common/test.js +0 -321
  54. package/lib/common/testLoader.js +0 -101
  55. package/lib/common/testType.js +0 -298
  56. package/lib/common/validators.js +0 -68
  57. package/lib/fsWatcher.js +0 -67
  58. package/lib/isomorphic/events.js +0 -77
  59. package/lib/isomorphic/folders.js +0 -30
  60. package/lib/isomorphic/stringInternPool.js +0 -69
  61. package/lib/isomorphic/teleReceiver.js +0 -521
  62. package/lib/isomorphic/teleSuiteUpdater.js +0 -157
  63. package/lib/isomorphic/testServerInterface.js +0 -16
  64. package/lib/isomorphic/testTree.js +0 -329
  65. package/lib/isomorphic/types.d.js +0 -16
  66. package/lib/loader/loaderMain.js +0 -59
  67. package/lib/matchers/matcherHint.js +0 -44
  68. package/lib/matchers/matchers.js +0 -383
  69. package/lib/matchers/toBeTruthy.js +0 -75
  70. package/lib/matchers/toEqual.js +0 -100
  71. package/lib/matchers/toHaveURL.js +0 -101
  72. package/lib/matchers/toMatchAriaSnapshot.js +0 -159
  73. package/lib/matchers/toMatchSnapshot.js +0 -342
  74. package/lib/matchers/toMatchText.js +0 -99
  75. package/lib/mcp/browser/browserContextFactory.js +0 -329
  76. package/lib/mcp/browser/browserServerBackend.js +0 -84
  77. package/lib/mcp/browser/config.js +0 -421
  78. package/lib/mcp/browser/context.js +0 -244
  79. package/lib/mcp/browser/response.js +0 -278
  80. package/lib/mcp/browser/sessionLog.js +0 -75
  81. package/lib/mcp/browser/tab.js +0 -343
  82. package/lib/mcp/browser/tools/common.js +0 -65
  83. package/lib/mcp/browser/tools/console.js +0 -46
  84. package/lib/mcp/browser/tools/dialogs.js +0 -60
  85. package/lib/mcp/browser/tools/evaluate.js +0 -61
  86. package/lib/mcp/browser/tools/files.js +0 -58
  87. package/lib/mcp/browser/tools/form.js +0 -63
  88. package/lib/mcp/browser/tools/install.js +0 -72
  89. package/lib/mcp/browser/tools/keyboard.js +0 -107
  90. package/lib/mcp/browser/tools/mouse.js +0 -107
  91. package/lib/mcp/browser/tools/navigate.js +0 -71
  92. package/lib/mcp/browser/tools/network.js +0 -63
  93. package/lib/mcp/browser/tools/open.js +0 -57
  94. package/lib/mcp/browser/tools/pdf.js +0 -49
  95. package/lib/mcp/browser/tools/runCode.js +0 -78
  96. package/lib/mcp/browser/tools/screenshot.js +0 -93
  97. package/lib/mcp/browser/tools/snapshot.js +0 -173
  98. package/lib/mcp/browser/tools/tabs.js +0 -67
  99. package/lib/mcp/browser/tools/tool.js +0 -47
  100. package/lib/mcp/browser/tools/tracing.js +0 -74
  101. package/lib/mcp/browser/tools/utils.js +0 -94
  102. package/lib/mcp/browser/tools/verify.js +0 -143
  103. package/lib/mcp/browser/tools/wait.js +0 -63
  104. package/lib/mcp/browser/tools.js +0 -84
  105. package/lib/mcp/browser/watchdog.js +0 -44
  106. package/lib/mcp/config.d.js +0 -16
  107. package/lib/mcp/extension/cdpRelay.js +0 -351
  108. package/lib/mcp/extension/extensionContextFactory.js +0 -76
  109. package/lib/mcp/extension/protocol.js +0 -28
  110. package/lib/mcp/index.js +0 -61
  111. package/lib/mcp/log.js +0 -35
  112. package/lib/mcp/program.js +0 -111
  113. package/lib/mcp/sdk/exports.js +0 -28
  114. package/lib/mcp/sdk/http.js +0 -152
  115. package/lib/mcp/sdk/inProcessTransport.js +0 -71
  116. package/lib/mcp/sdk/server.js +0 -223
  117. package/lib/mcp/sdk/tool.js +0 -47
  118. package/lib/mcp/terminal/cli.js +0 -296
  119. package/lib/mcp/terminal/command.js +0 -56
  120. package/lib/mcp/terminal/commands.js +0 -333
  121. package/lib/mcp/terminal/daemon.js +0 -129
  122. package/lib/mcp/terminal/help.json +0 -32
  123. package/lib/mcp/terminal/helpGenerator.js +0 -88
  124. package/lib/mcp/terminal/socketConnection.js +0 -80
  125. package/lib/plugins/gitCommitInfoPlugin.js +0 -198
  126. package/lib/plugins/index.js +0 -28
  127. package/lib/plugins/webServerPlugin.js +0 -237
  128. package/lib/reporters/base.js +0 -634
  129. package/lib/reporters/blob.js +0 -138
  130. package/lib/reporters/dot.js +0 -99
  131. package/lib/reporters/empty.js +0 -32
  132. package/lib/reporters/github.js +0 -128
  133. package/lib/reporters/html.js +0 -633
  134. package/lib/reporters/internalReporter.js +0 -138
  135. package/lib/reporters/json.js +0 -254
  136. package/lib/reporters/junit.js +0 -232
  137. package/lib/reporters/line.js +0 -131
  138. package/lib/reporters/list.js +0 -253
  139. package/lib/reporters/listModeReporter.js +0 -69
  140. package/lib/reporters/markdown.js +0 -144
  141. package/lib/reporters/merge.js +0 -558
  142. package/lib/reporters/multiplexer.js +0 -112
  143. package/lib/reporters/reporterV2.js +0 -102
  144. package/lib/reporters/smoothdeploy.js +0 -333
  145. package/lib/reporters/teleEmitter.js +0 -317
  146. package/lib/reporters/versions/blobV1.js +0 -16
  147. package/lib/runner/dispatcher.js +0 -531
  148. package/lib/runner/failureTracker.js +0 -72
  149. package/lib/runner/lastRun.js +0 -77
  150. package/lib/runner/loadUtils.js +0 -334
  151. package/lib/runner/loaderHost.js +0 -89
  152. package/lib/runner/processHost.js +0 -180
  153. package/lib/runner/projectUtils.js +0 -241
  154. package/lib/runner/rebase.js +0 -189
  155. package/lib/runner/reporters.js +0 -140
  156. package/lib/runner/sigIntWatcher.js +0 -96
  157. package/lib/runner/storage.js +0 -91
  158. package/lib/runner/taskRunner.js +0 -127
  159. package/lib/runner/tasks.js +0 -410
  160. package/lib/runner/testGroups.js +0 -125
  161. package/lib/runner/testRunner.js +0 -398
  162. package/lib/runner/testServer.js +0 -269
  163. package/lib/runner/uiModeReporter.js +0 -30
  164. package/lib/runner/vcs.js +0 -72
  165. package/lib/runner/watchMode.js +0 -396
  166. package/lib/runner/workerHost.js +0 -104
  167. package/lib/third_party/pirates.js +0 -62
  168. package/lib/third_party/tsconfig-loader.js +0 -103
  169. package/lib/transform/babelBundleImpl.js +0 -461
  170. package/lib/transform/compilationCache.js +0 -274
  171. package/lib/transform/md.js +0 -221
  172. package/lib/transform/portTransport.js +0 -67
  173. package/lib/transform/transform.js +0 -303
  174. package/lib/utilsBundle.js +0 -50
  175. package/lib/utilsBundleImpl.js +0 -103
  176. package/lib/worker/fixtureRunner.js +0 -262
  177. package/lib/worker/testInfo.js +0 -536
  178. package/lib/worker/testTracing.js +0 -345
  179. package/lib/worker/timeoutManager.js +0 -174
  180. package/lib/worker/util.js +0 -31
  181. package/lib/worker/workerMain.js +0 -530
  182. /package/lib/{common/globals.js → globals.js} +0 -0
@@ -1,531 +0,0 @@
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 dispatcher_exports = {};
20
- __export(dispatcher_exports, {
21
- Dispatcher: () => Dispatcher
22
- });
23
- module.exports = __toCommonJS(dispatcher_exports);
24
- var import_utils = require("playwright-core/lib/utils");
25
- var import_utils2 = require("playwright-core/lib/utils");
26
- var import_rebase = require("./rebase");
27
- var import_workerHost = require("./workerHost");
28
- var import_ipc = require("../common/ipc");
29
- var import_internalReporter = require("../reporters/internalReporter");
30
- var import_util = require("../util");
31
- var import_storage = require("./storage");
32
- class Dispatcher {
33
- constructor(config, reporter, failureTracker) {
34
- this._workerSlots = [];
35
- this._queue = [];
36
- this._workerLimitPerProjectId = /* @__PURE__ */ new Map();
37
- this._queuedOrRunningHashCount = /* @__PURE__ */ new Map();
38
- this._finished = new import_utils.ManualPromise();
39
- this._isStopped = true;
40
- this._extraEnvByProjectId = /* @__PURE__ */ new Map();
41
- this._producedEnvByProjectId = /* @__PURE__ */ new Map();
42
- this._config = config;
43
- this._reporter = reporter;
44
- this._failureTracker = failureTracker;
45
- for (const project of config.projects) {
46
- if (project.workers)
47
- this._workerLimitPerProjectId.set(project.id, project.workers);
48
- }
49
- }
50
- _findFirstJobToRun() {
51
- for (let index = 0; index < this._queue.length; index++) {
52
- const job = this._queue[index];
53
- const projectIdWorkerLimit = this._workerLimitPerProjectId.get(job.projectId);
54
- if (!projectIdWorkerLimit)
55
- return index;
56
- const runningWorkersWithSameProjectId = this._workerSlots.filter((w) => w.busy && w.worker && w.worker.projectId() === job.projectId).length;
57
- if (runningWorkersWithSameProjectId < projectIdWorkerLimit)
58
- return index;
59
- }
60
- return -1;
61
- }
62
- _scheduleJob() {
63
- if (this._isStopped)
64
- return;
65
- const jobIndex = this._findFirstJobToRun();
66
- if (jobIndex === -1)
67
- return;
68
- const job = this._queue[jobIndex];
69
- let workerIndex = this._workerSlots.findIndex((w) => !w.busy && w.worker && w.worker.hash() === job.workerHash && !w.worker.didSendStop());
70
- if (workerIndex === -1)
71
- workerIndex = this._workerSlots.findIndex((w) => !w.busy);
72
- if (workerIndex === -1) {
73
- return;
74
- }
75
- this._queue.splice(jobIndex, 1);
76
- const jobDispatcher = new JobDispatcher(job, this._config, this._reporter, this._failureTracker, () => this.stop().catch(() => {
77
- }));
78
- this._workerSlots[workerIndex].busy = true;
79
- this._workerSlots[workerIndex].jobDispatcher = jobDispatcher;
80
- void this._runJobInWorker(workerIndex, jobDispatcher).then(() => {
81
- this._workerSlots[workerIndex].jobDispatcher = void 0;
82
- this._workerSlots[workerIndex].busy = false;
83
- this._checkFinished();
84
- this._scheduleJob();
85
- });
86
- }
87
- async _runJobInWorker(index, jobDispatcher) {
88
- const job = jobDispatcher.job;
89
- if (jobDispatcher.skipWholeJob())
90
- return;
91
- let worker = this._workerSlots[index].worker;
92
- if (worker && (worker.hash() !== job.workerHash || worker.didSendStop())) {
93
- await worker.stop();
94
- worker = void 0;
95
- if (this._isStopped)
96
- return;
97
- }
98
- let startError;
99
- if (!worker) {
100
- worker = this._createWorker(job, index, (0, import_ipc.serializeConfig)(this._config, true));
101
- this._workerSlots[index].worker = worker;
102
- worker.on("exit", () => this._workerSlots[index].worker = void 0);
103
- startError = await worker.start();
104
- if (this._isStopped)
105
- return;
106
- }
107
- if (startError)
108
- jobDispatcher.onExit(startError);
109
- else
110
- jobDispatcher.runInWorker(worker);
111
- const result = await jobDispatcher.jobResult;
112
- this._updateCounterForWorkerHash(job.workerHash, -1);
113
- if (result.didFail)
114
- void worker.stop(
115
- true
116
- /* didFail */
117
- );
118
- else if (this._isWorkerRedundant(worker))
119
- void worker.stop();
120
- if (!this._isStopped && result.newJob) {
121
- this._queue.unshift(result.newJob);
122
- this._updateCounterForWorkerHash(result.newJob.workerHash, 1);
123
- }
124
- }
125
- _checkFinished() {
126
- if (this._finished.isDone())
127
- return;
128
- if (this._queue.length && !this._isStopped)
129
- return;
130
- if (this._workerSlots.some((w) => w.busy))
131
- return;
132
- this._finished.resolve();
133
- }
134
- _isWorkerRedundant(worker) {
135
- let workersWithSameHash = 0;
136
- for (const slot of this._workerSlots) {
137
- if (slot.worker && !slot.worker.didSendStop() && slot.worker.hash() === worker.hash())
138
- workersWithSameHash++;
139
- }
140
- return workersWithSameHash > this._queuedOrRunningHashCount.get(worker.hash());
141
- }
142
- _updateCounterForWorkerHash(hash, delta) {
143
- this._queuedOrRunningHashCount.set(hash, delta + (this._queuedOrRunningHashCount.get(hash) || 0));
144
- }
145
- async run(testGroups, extraEnvByProjectId) {
146
- this._extraEnvByProjectId = extraEnvByProjectId;
147
- this._queue = testGroups;
148
- for (const group of testGroups)
149
- this._updateCounterForWorkerHash(group.workerHash, 1);
150
- this._isStopped = false;
151
- this._workerSlots = [];
152
- if (this._failureTracker.hasReachedMaxFailures())
153
- void this.stop();
154
- for (let i = 0; i < this._config.config.workers; i++)
155
- this._workerSlots.push({ busy: false });
156
- for (let i = 0; i < this._workerSlots.length; i++)
157
- this._scheduleJob();
158
- this._checkFinished();
159
- await this._finished;
160
- }
161
- _createWorker(testGroup, parallelIndex, loaderData) {
162
- const projectConfig = this._config.projects.find((p) => p.id === testGroup.projectId);
163
- const outputDir = projectConfig.project.outputDir;
164
- const worker = new import_workerHost.WorkerHost(testGroup, {
165
- parallelIndex,
166
- config: loaderData,
167
- extraEnv: this._extraEnvByProjectId.get(testGroup.projectId) || {},
168
- outputDir,
169
- pauseOnError: this._failureTracker.pauseOnError(),
170
- pauseAtEnd: this._failureTracker.pauseAtEnd(projectConfig)
171
- });
172
- const handleOutput = (params) => {
173
- const chunk = chunkFromParams(params);
174
- if (worker.didFail()) {
175
- return { chunk };
176
- }
177
- const currentlyRunning = this._workerSlots[parallelIndex].jobDispatcher?.currentlyRunning();
178
- if (!currentlyRunning)
179
- return { chunk };
180
- return { chunk, test: currentlyRunning.test, result: currentlyRunning.result };
181
- };
182
- worker.on("stdOut", (params) => {
183
- const { chunk, test, result } = handleOutput(params);
184
- result?.stdout.push(chunk);
185
- this._reporter.onStdOut?.(chunk, test, result);
186
- });
187
- worker.on("stdErr", (params) => {
188
- const { chunk, test, result } = handleOutput(params);
189
- result?.stderr.push(chunk);
190
- this._reporter.onStdErr?.(chunk, test, result);
191
- });
192
- worker.on("teardownErrors", (params) => {
193
- this._failureTracker.onWorkerError();
194
- for (const error of params.fatalErrors)
195
- this._reporter.onError?.(error);
196
- });
197
- worker.on("exit", () => {
198
- const producedEnv = this._producedEnvByProjectId.get(testGroup.projectId) || {};
199
- this._producedEnvByProjectId.set(testGroup.projectId, { ...producedEnv, ...worker.producedEnv() });
200
- });
201
- worker.onRequest("cloneStorage", async (params) => {
202
- return await import_storage.Storage.clone(params.storageFile, outputDir);
203
- });
204
- worker.onRequest("upstreamStorage", async (params) => {
205
- await import_storage.Storage.upstream(params.storageFile, params.storageOutFile);
206
- });
207
- return worker;
208
- }
209
- producedEnvByProjectId() {
210
- return this._producedEnvByProjectId;
211
- }
212
- async stop() {
213
- if (this._isStopped)
214
- return;
215
- this._isStopped = true;
216
- await Promise.all(this._workerSlots.map(({ worker }) => worker?.stop()));
217
- this._checkFinished();
218
- }
219
- }
220
- class JobDispatcher {
221
- constructor(job, config, reporter, failureTracker, stopCallback) {
222
- this.jobResult = new import_utils.ManualPromise();
223
- this._listeners = [];
224
- this._failedTests = /* @__PURE__ */ new Set();
225
- this._failedWithNonRetriableError = /* @__PURE__ */ new Set();
226
- this._remainingByTestId = /* @__PURE__ */ new Map();
227
- this._dataByTestId = /* @__PURE__ */ new Map();
228
- this._parallelIndex = 0;
229
- this._workerIndex = 0;
230
- this.job = job;
231
- this._config = config;
232
- this._reporter = reporter;
233
- this._failureTracker = failureTracker;
234
- this._stopCallback = stopCallback;
235
- this._remainingByTestId = new Map(this.job.tests.map((e) => [e.id, e]));
236
- }
237
- _onTestBegin(params) {
238
- const test = this._remainingByTestId.get(params.testId);
239
- if (!test) {
240
- return;
241
- }
242
- const result = test._appendTestResult();
243
- this._dataByTestId.set(test.id, { test, result, steps: /* @__PURE__ */ new Map() });
244
- result.parallelIndex = this._parallelIndex;
245
- result.workerIndex = this._workerIndex;
246
- result.startTime = new Date(params.startWallTime);
247
- this._reporter.onTestBegin?.(test, result);
248
- this._currentlyRunning = { test, result };
249
- }
250
- _onTestEnd(params) {
251
- if (this._failureTracker.hasReachedMaxFailures()) {
252
- params.status = "interrupted";
253
- params.errors = [];
254
- }
255
- const data = this._dataByTestId.get(params.testId);
256
- if (!data) {
257
- return;
258
- }
259
- this._dataByTestId.delete(params.testId);
260
- this._remainingByTestId.delete(params.testId);
261
- const { result, test } = data;
262
- result.duration = params.duration;
263
- result.errors = params.errors;
264
- result.error = result.errors[0];
265
- result.status = params.status;
266
- result.annotations = params.annotations;
267
- test.annotations = [...params.annotations];
268
- test.expectedStatus = params.expectedStatus;
269
- test.timeout = params.timeout;
270
- const isFailure = result.status !== "skipped" && result.status !== test.expectedStatus;
271
- if (isFailure)
272
- this._failedTests.add(test);
273
- if (params.hasNonRetriableError)
274
- this._addNonretriableTestAndSerialModeParents(test);
275
- this._reportTestEnd(test, result);
276
- this._currentlyRunning = void 0;
277
- }
278
- _addNonretriableTestAndSerialModeParents(test) {
279
- this._failedWithNonRetriableError.add(test);
280
- for (let parent = test.parent; parent; parent = parent.parent) {
281
- if (parent._parallelMode === "serial")
282
- this._failedWithNonRetriableError.add(parent);
283
- }
284
- }
285
- _onStepBegin(params) {
286
- const data = this._dataByTestId.get(params.testId);
287
- if (!data) {
288
- return;
289
- }
290
- const { result, steps, test } = data;
291
- const parentStep = params.parentStepId ? steps.get(params.parentStepId) : void 0;
292
- const step = {
293
- title: params.title,
294
- titlePath: () => {
295
- const parentPath = parentStep?.titlePath() || [];
296
- return [...parentPath, params.title];
297
- },
298
- parent: parentStep,
299
- category: params.category,
300
- startTime: new Date(params.wallTime),
301
- duration: -1,
302
- steps: [],
303
- attachments: [],
304
- annotations: [],
305
- location: params.location,
306
- _stepId: params.stepId
307
- };
308
- steps.set(params.stepId, step);
309
- (parentStep || result).steps.push(step);
310
- this._reporter.onStepBegin?.(test, result, step);
311
- }
312
- _onStepEnd(params) {
313
- const data = this._dataByTestId.get(params.testId);
314
- if (!data) {
315
- return;
316
- }
317
- const { result, steps, test } = data;
318
- const step = steps.get(params.stepId);
319
- if (!step) {
320
- this._reporter.onStdErr?.("Internal error: step end without step begin: " + params.stepId, test, result);
321
- return;
322
- }
323
- step.duration = params.wallTime - step.startTime.getTime();
324
- if (params.error)
325
- step.error = params.error;
326
- if (params.suggestedRebaseline)
327
- (0, import_rebase.addSuggestedRebaseline)(step.location, params.suggestedRebaseline);
328
- step.annotations = params.annotations;
329
- steps.delete(params.stepId);
330
- this._reporter.onStepEnd?.(test, result, step);
331
- }
332
- _onAttach(params) {
333
- const data = this._dataByTestId.get(params.testId);
334
- if (!data) {
335
- return;
336
- }
337
- const attachment = {
338
- name: params.name,
339
- path: params.path,
340
- contentType: params.contentType,
341
- body: params.body !== void 0 ? Buffer.from(params.body, "base64") : void 0
342
- };
343
- data.result.attachments.push(attachment);
344
- if (params.stepId) {
345
- const step = data.steps.get(params.stepId);
346
- if (step)
347
- step.attachments.push(attachment);
348
- else
349
- this._reporter.onStdErr?.("Internal error: step id not found: " + params.stepId);
350
- }
351
- }
352
- _failTestWithErrors(test, errors) {
353
- const runData = this._dataByTestId.get(test.id);
354
- let result;
355
- if (runData) {
356
- result = runData.result;
357
- } else {
358
- result = test._appendTestResult();
359
- this._reporter.onTestBegin?.(test, result);
360
- }
361
- result.errors = [...errors];
362
- result.error = result.errors[0];
363
- result.status = errors.length ? "failed" : "skipped";
364
- this._reportTestEnd(test, result);
365
- this._failedTests.add(test);
366
- }
367
- _massSkipTestsFromRemaining(testIds, errors) {
368
- for (const test of this._remainingByTestId.values()) {
369
- if (!testIds.has(test.id))
370
- continue;
371
- if (!this._failureTracker.hasReachedMaxFailures()) {
372
- this._failTestWithErrors(test, errors);
373
- errors = [];
374
- }
375
- this._remainingByTestId.delete(test.id);
376
- }
377
- if (errors.length) {
378
- this._failureTracker.onWorkerError();
379
- for (const error of errors)
380
- this._reporter.onError?.(error);
381
- }
382
- }
383
- _onDone(params) {
384
- if (!this._remainingByTestId.size && !this._failedTests.size && !params.fatalErrors.length && !params.skipTestsDueToSetupFailure.length && !params.fatalUnknownTestIds && !params.unexpectedExitError && !params.stoppedDueToUnhandledErrorInTestFail) {
385
- this._finished({ didFail: false });
386
- return;
387
- }
388
- for (const testId of params.fatalUnknownTestIds || []) {
389
- const test = this._remainingByTestId.get(testId);
390
- if (test) {
391
- this._remainingByTestId.delete(testId);
392
- this._failTestWithErrors(test, [{ message: `Test not found in the worker process. Make sure test title does not change.` }]);
393
- }
394
- }
395
- if (params.fatalErrors.length) {
396
- this._massSkipTestsFromRemaining(new Set(this._remainingByTestId.keys()), params.fatalErrors);
397
- }
398
- this._massSkipTestsFromRemaining(new Set(params.skipTestsDueToSetupFailure), []);
399
- if (params.unexpectedExitError) {
400
- if (this._currentlyRunning)
401
- this._massSkipTestsFromRemaining(/* @__PURE__ */ new Set([this._currentlyRunning.test.id]), [params.unexpectedExitError]);
402
- else
403
- this._massSkipTestsFromRemaining(new Set(this._remainingByTestId.keys()), [params.unexpectedExitError]);
404
- }
405
- const retryCandidates = /* @__PURE__ */ new Set();
406
- const serialSuitesWithFailures = /* @__PURE__ */ new Set();
407
- for (const failedTest of this._failedTests) {
408
- if (this._failedWithNonRetriableError.has(failedTest))
409
- continue;
410
- retryCandidates.add(failedTest);
411
- let outermostSerialSuite;
412
- for (let parent = failedTest.parent; parent; parent = parent.parent) {
413
- if (parent._parallelMode === "serial")
414
- outermostSerialSuite = parent;
415
- }
416
- if (outermostSerialSuite && !this._failedWithNonRetriableError.has(outermostSerialSuite))
417
- serialSuitesWithFailures.add(outermostSerialSuite);
418
- }
419
- const testsBelongingToSomeSerialSuiteWithFailures = [...this._remainingByTestId.values()].filter((test) => {
420
- let parent = test.parent;
421
- while (parent && !serialSuitesWithFailures.has(parent))
422
- parent = parent.parent;
423
- return !!parent;
424
- });
425
- this._massSkipTestsFromRemaining(new Set(testsBelongingToSomeSerialSuiteWithFailures.map((test) => test.id)), []);
426
- for (const serialSuite of serialSuitesWithFailures) {
427
- serialSuite.allTests().forEach((test) => retryCandidates.add(test));
428
- }
429
- const remaining = [...this._remainingByTestId.values()];
430
- for (const test of retryCandidates) {
431
- if (test.results.length < test.retries + 1)
432
- remaining.push(test);
433
- }
434
- const newJob = remaining.length ? { ...this.job, tests: remaining } : void 0;
435
- this._finished({ didFail: true, newJob });
436
- }
437
- onExit(data) {
438
- const unexpectedExitError = data.unexpectedly ? {
439
- message: `Error: worker process exited unexpectedly (code=${data.code}, signal=${data.signal})`
440
- } : void 0;
441
- this._onDone({ skipTestsDueToSetupFailure: [], fatalErrors: [], unexpectedExitError });
442
- }
443
- _finished(result) {
444
- import_utils.eventsHelper.removeEventListeners(this._listeners);
445
- this.jobResult.resolve(result);
446
- }
447
- runInWorker(worker) {
448
- this._parallelIndex = worker.parallelIndex;
449
- this._workerIndex = worker.workerIndex;
450
- const runPayload = {
451
- file: this.job.requireFile,
452
- entries: this.job.tests.map((test) => {
453
- return { testId: test.id, retry: test.results.length };
454
- })
455
- };
456
- worker.runTestGroup(runPayload);
457
- this._listeners = [
458
- import_utils.eventsHelper.addEventListener(worker, "testBegin", this._onTestBegin.bind(this)),
459
- import_utils.eventsHelper.addEventListener(worker, "testEnd", this._onTestEnd.bind(this)),
460
- import_utils.eventsHelper.addEventListener(worker, "stepBegin", this._onStepBegin.bind(this)),
461
- import_utils.eventsHelper.addEventListener(worker, "stepEnd", this._onStepEnd.bind(this)),
462
- import_utils.eventsHelper.addEventListener(worker, "attach", this._onAttach.bind(this)),
463
- import_utils.eventsHelper.addEventListener(worker, "testPaused", this._onTestPaused.bind(this, worker)),
464
- import_utils.eventsHelper.addEventListener(worker, "done", this._onDone.bind(this)),
465
- import_utils.eventsHelper.addEventListener(worker, "exit", this.onExit.bind(this))
466
- ];
467
- }
468
- _onTestPaused(worker, params) {
469
- const data = this._dataByTestId.get(params.testId);
470
- if (!data)
471
- return;
472
- const { result, test } = data;
473
- const sendMessage = async (message) => {
474
- try {
475
- if (this.jobResult.isDone())
476
- throw new Error("Test has already stopped");
477
- const response = await worker.sendCustomMessage({ testId: test.id, request: message.request });
478
- if (response.error)
479
- (0, import_internalReporter.addLocationAndSnippetToError)(this._config.config, response.error);
480
- return response;
481
- } catch (e) {
482
- const error = (0, import_util.serializeError)(e);
483
- (0, import_internalReporter.addLocationAndSnippetToError)(this._config.config, error);
484
- return { response: void 0, error };
485
- }
486
- };
487
- result.status = params.status;
488
- result.errors = params.errors;
489
- result.error = result.errors[0];
490
- void this._reporter.onTestPaused?.(test, result).then(() => {
491
- worker.sendResume({});
492
- });
493
- this._failureTracker.onTestPaused?.({ ...params, sendMessage });
494
- }
495
- skipWholeJob() {
496
- const allTestsSkipped = this.job.tests.every((test) => test.expectedStatus === "skipped");
497
- if (allTestsSkipped && !this._failureTracker.hasReachedMaxFailures()) {
498
- for (const test of this.job.tests) {
499
- const result = test._appendTestResult();
500
- this._reporter.onTestBegin?.(test, result);
501
- result.status = "skipped";
502
- result.annotations = [...test.annotations];
503
- this._reportTestEnd(test, result);
504
- }
505
- return true;
506
- }
507
- return false;
508
- }
509
- currentlyRunning() {
510
- return this._currentlyRunning;
511
- }
512
- _reportTestEnd(test, result) {
513
- this._reporter.onTestEnd?.(test, result);
514
- const hadMaxFailures = this._failureTracker.hasReachedMaxFailures();
515
- this._failureTracker.onTestEnd(test, result);
516
- if (this._failureTracker.hasReachedMaxFailures()) {
517
- this._stopCallback();
518
- if (!hadMaxFailures)
519
- this._reporter.onError?.({ message: import_utils2.colors.red(`Testing stopped early after ${this._failureTracker.maxFailures()} maximum allowed failures.`) });
520
- }
521
- }
522
- }
523
- function chunkFromParams(params) {
524
- if (typeof params.text === "string")
525
- return params.text;
526
- return Buffer.from(params.buffer, "base64");
527
- }
528
- // Annotate the CommonJS export names for ESM import in node:
529
- 0 && (module.exports = {
530
- Dispatcher
531
- });
@@ -1,72 +0,0 @@
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 failureTracker_exports = {};
20
- __export(failureTracker_exports, {
21
- FailureTracker: () => FailureTracker
22
- });
23
- module.exports = __toCommonJS(failureTracker_exports);
24
- class FailureTracker {
25
- constructor(config, options) {
26
- this._failureCount = 0;
27
- this._hasWorkerErrors = false;
28
- this._topLevelProjects = [];
29
- this._config = config;
30
- this._pauseOnError = !!options?.pauseOnError;
31
- this._pauseAtEnd = !!options?.pauseAtEnd;
32
- }
33
- onRootSuite(rootSuite, topLevelProjects) {
34
- this._rootSuite = rootSuite;
35
- this._topLevelProjects = topLevelProjects;
36
- }
37
- onTestEnd(test, result) {
38
- if (test.outcome() === "unexpected" && test.results.length > test.retries)
39
- ++this._failureCount;
40
- }
41
- onWorkerError() {
42
- this._hasWorkerErrors = true;
43
- }
44
- pauseOnError() {
45
- return this._pauseOnError;
46
- }
47
- pauseAtEnd(inProject) {
48
- return this._topLevelProjects.includes(inProject) && this._pauseAtEnd;
49
- }
50
- hasReachedMaxFailures() {
51
- return this.maxFailures() > 0 && this._failureCount >= this.maxFailures();
52
- }
53
- hasWorkerErrors() {
54
- return this._hasWorkerErrors;
55
- }
56
- result() {
57
- return this._hasWorkerErrors || this.hasReachedMaxFailures() || this.hasFailedTests() || this._config.failOnFlakyTests && this.hasFlakyTests() ? "failed" : "passed";
58
- }
59
- hasFailedTests() {
60
- return this._rootSuite?.allTests().some((test) => !test.ok());
61
- }
62
- hasFlakyTests() {
63
- return this._rootSuite?.allTests().some((test) => test.outcome() === "flaky");
64
- }
65
- maxFailures() {
66
- return this._config.config.maxFailures;
67
- }
68
- }
69
- // Annotate the CommonJS export names for ESM import in node:
70
- 0 && (module.exports = {
71
- FailureTracker
72
- });
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var lastRun_exports = {};
30
- __export(lastRun_exports, {
31
- LastRunReporter: () => LastRunReporter
32
- });
33
- module.exports = __toCommonJS(lastRun_exports);
34
- var import_fs = __toESM(require("fs"));
35
- var import_path = __toESM(require("path"));
36
- var import_projectUtils = require("./projectUtils");
37
- class LastRunReporter {
38
- constructor(config) {
39
- this._config = config;
40
- const [project] = (0, import_projectUtils.filterProjects)(config.projects, config.cliProjectFilter);
41
- if (project)
42
- this._lastRunFile = import_path.default.join(project.project.outputDir, ".last-run.json");
43
- }
44
- async filterLastFailed() {
45
- if (!this._lastRunFile)
46
- return;
47
- try {
48
- const lastRunInfo = JSON.parse(await import_fs.default.promises.readFile(this._lastRunFile, "utf8"));
49
- const failedTestIds = new Set(lastRunInfo.failedTests);
50
- this._config.postShardTestFilters.push((test) => failedTestIds.has(test.id));
51
- } catch {
52
- }
53
- }
54
- version() {
55
- return "v2";
56
- }
57
- printsToStdio() {
58
- return false;
59
- }
60
- onBegin(suite) {
61
- this._suite = suite;
62
- }
63
- async onEnd(result) {
64
- if (!this._lastRunFile || this._config.cliListOnly)
65
- return;
66
- const lastRunInfo = {
67
- status: result.status,
68
- failedTests: this._suite?.allTests().filter((t) => !t.ok()).map((t) => t.id) || []
69
- };
70
- await import_fs.default.promises.mkdir(import_path.default.dirname(this._lastRunFile), { recursive: true });
71
- await import_fs.default.promises.writeFile(this._lastRunFile, JSON.stringify(lastRunInfo, void 0, 2));
72
- }
73
- }
74
- // Annotate the CommonJS export names for ESM import in node:
75
- 0 && (module.exports = {
76
- LastRunReporter
77
- });