@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,523 @@
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 teleReceiver_exports = {};
20
+ __export(teleReceiver_exports, {
21
+ TeleReporterReceiver: () => TeleReporterReceiver,
22
+ TeleSuite: () => TeleSuite,
23
+ TeleTestCase: () => TeleTestCase,
24
+ TeleTestResult: () => TeleTestResult,
25
+ baseFullConfig: () => baseFullConfig,
26
+ computeTestCaseOutcome: () => computeTestCaseOutcome,
27
+ parseRegexPatterns: () => parseRegexPatterns,
28
+ serializeRegexPatterns: () => serializeRegexPatterns
29
+ });
30
+ module.exports = __toCommonJS(teleReceiver_exports);
31
+ class TeleReporterReceiver {
32
+ constructor(reporter, options = {}) {
33
+ this.isListing = false;
34
+ this._tests = /* @__PURE__ */ new Map();
35
+ this._rootSuite = new TeleSuite("", "root");
36
+ this._options = options;
37
+ this._reporter = reporter;
38
+ }
39
+ reset() {
40
+ this._rootSuite._entries = [];
41
+ this._tests.clear();
42
+ }
43
+ dispatch(message) {
44
+ const { method, params } = message;
45
+ if (method === "onConfigure") {
46
+ this._onConfigure(params.config);
47
+ return;
48
+ }
49
+ if (method === "onProject") {
50
+ this._onProject(params.project);
51
+ return;
52
+ }
53
+ if (method === "onBegin") {
54
+ this._onBegin();
55
+ return;
56
+ }
57
+ if (method === "onTestBegin") {
58
+ this._onTestBegin(params.testId, params.result);
59
+ return;
60
+ }
61
+ if (method === "onTestPaused") {
62
+ this._onTestPaused(params.testId, params.resultId, params.stepId, params.errors);
63
+ return;
64
+ }
65
+ if (method === "onTestEnd") {
66
+ this._onTestEnd(params.test, params.result);
67
+ return;
68
+ }
69
+ if (method === "onStepBegin") {
70
+ this._onStepBegin(params.testId, params.resultId, params.step);
71
+ return;
72
+ }
73
+ if (method === "onAttach") {
74
+ this._onAttach(params.testId, params.resultId, params.attachments);
75
+ return;
76
+ }
77
+ if (method === "onStepEnd") {
78
+ this._onStepEnd(params.testId, params.resultId, params.step);
79
+ return;
80
+ }
81
+ if (method === "onError") {
82
+ this._onError(params.error);
83
+ return;
84
+ }
85
+ if (method === "onStdIO") {
86
+ this._onStdIO(params.type, params.testId, params.resultId, params.data, params.isBase64);
87
+ return;
88
+ }
89
+ if (method === "onEnd")
90
+ return this._onEnd(params.result);
91
+ if (method === "onExit")
92
+ return this._onExit();
93
+ }
94
+ _onConfigure(config) {
95
+ this._rootDir = config.rootDir;
96
+ this._config = this._parseConfig(config);
97
+ this._reporter.onConfigure?.(this._config);
98
+ }
99
+ _onProject(project) {
100
+ let projectSuite = this._options.mergeProjects ? this._rootSuite.suites.find((suite) => suite.project().name === project.name) : void 0;
101
+ if (!projectSuite) {
102
+ projectSuite = new TeleSuite(project.name, "project");
103
+ this._rootSuite._addSuite(projectSuite);
104
+ }
105
+ projectSuite._project = this._parseProject(project);
106
+ for (const suite of project.suites)
107
+ this._mergeSuiteInto(suite, projectSuite);
108
+ }
109
+ _onBegin() {
110
+ this._reporter.onBegin?.(this._rootSuite);
111
+ }
112
+ _onTestBegin(testId, payload) {
113
+ const test = this._tests.get(testId);
114
+ if (this._options.clearPreviousResultsWhenTestBegins)
115
+ test.results = [];
116
+ const testResult = test._createTestResult(payload.id);
117
+ testResult.retry = payload.retry;
118
+ testResult.workerIndex = payload.workerIndex;
119
+ testResult.parallelIndex = payload.parallelIndex;
120
+ testResult.shardIndex = payload.shardIndex;
121
+ testResult.setStartTimeNumber(payload.startTime);
122
+ this._reporter.onTestBegin?.(test, testResult);
123
+ }
124
+ _onTestPaused(testId, resultId, stepId, errors) {
125
+ const test = this._tests.get(testId);
126
+ const result = test.results.find((r) => r._id === resultId);
127
+ const step = result._stepMap.get(stepId);
128
+ result.errors.push(...errors);
129
+ result.error = result.errors[0];
130
+ void this._reporter.onTestPaused?.(test, result, step);
131
+ }
132
+ _onTestEnd(testEndPayload, payload) {
133
+ const test = this._tests.get(testEndPayload.testId);
134
+ test.timeout = testEndPayload.timeout;
135
+ test.expectedStatus = testEndPayload.expectedStatus;
136
+ const result = test.results.find((r) => r._id === payload.id);
137
+ result.duration = payload.duration;
138
+ result.status = payload.status;
139
+ result.errors.push(...payload.errors ?? []);
140
+ result.error = result.errors[0];
141
+ if (!!payload.attachments)
142
+ result.attachments = this._parseAttachments(payload.attachments);
143
+ if (payload.annotations) {
144
+ this._absoluteAnnotationLocationsInplace(payload.annotations);
145
+ result.annotations = payload.annotations;
146
+ test.annotations = payload.annotations;
147
+ }
148
+ this._reporter.onTestEnd?.(test, result);
149
+ result._stepMap = /* @__PURE__ */ new Map();
150
+ }
151
+ _onStepBegin(testId, resultId, payload) {
152
+ const test = this._tests.get(testId);
153
+ const result = test.results.find((r) => r._id === resultId);
154
+ const parentStep = payload.parentStepId ? result._stepMap.get(payload.parentStepId) : void 0;
155
+ const location = this._absoluteLocation(payload.location);
156
+ const step = new TeleTestStep(payload, parentStep, location, result);
157
+ if (parentStep)
158
+ parentStep.steps.push(step);
159
+ else
160
+ result.steps.push(step);
161
+ result._stepMap.set(payload.id, step);
162
+ this._reporter.onStepBegin?.(test, result, step);
163
+ }
164
+ _onStepEnd(testId, resultId, payload) {
165
+ const test = this._tests.get(testId);
166
+ const result = test.results.find((r) => r._id === resultId);
167
+ const step = result._stepMap.get(payload.id);
168
+ step._endPayload = payload;
169
+ step.duration = payload.duration;
170
+ step.error = payload.error;
171
+ this._reporter.onStepEnd?.(test, result, step);
172
+ }
173
+ _onAttach(testId, resultId, attachments) {
174
+ const test = this._tests.get(testId);
175
+ const result = test.results.find((r) => r._id === resultId);
176
+ result.attachments.push(...attachments.map((a) => ({
177
+ name: a.name,
178
+ contentType: a.contentType,
179
+ path: a.path,
180
+ body: a.base64 && globalThis.Buffer ? Buffer.from(a.base64, "base64") : void 0
181
+ })));
182
+ }
183
+ _onError(error) {
184
+ this._reporter.onError?.(error);
185
+ }
186
+ _onStdIO(type, testId, resultId, data, isBase64) {
187
+ const chunk = isBase64 ? globalThis.Buffer ? Buffer.from(data, "base64") : atob(data) : data;
188
+ const test = testId ? this._tests.get(testId) : void 0;
189
+ const result = test && resultId ? test.results.find((r) => r._id === resultId) : void 0;
190
+ if (type === "stdout") {
191
+ result?.stdout.push(chunk);
192
+ this._reporter.onStdOut?.(chunk, test, result);
193
+ } else {
194
+ result?.stderr.push(chunk);
195
+ this._reporter.onStdErr?.(chunk, test, result);
196
+ }
197
+ }
198
+ async _onEnd(result) {
199
+ await this._reporter.onEnd?.({
200
+ status: result.status,
201
+ startTime: new Date(result.startTime),
202
+ duration: result.duration
203
+ });
204
+ }
205
+ _onExit() {
206
+ return this._reporter.onExit?.();
207
+ }
208
+ _parseConfig(config) {
209
+ const result = { ...baseFullConfig, ...config };
210
+ if (this._options.configOverrides) {
211
+ result.configFile = this._options.configOverrides.configFile;
212
+ result.reportSlowTests = this._options.configOverrides.reportSlowTests;
213
+ result.quiet = this._options.configOverrides.quiet;
214
+ result.reporter = [...this._options.configOverrides.reporter];
215
+ }
216
+ return result;
217
+ }
218
+ _parseProject(project) {
219
+ return {
220
+ metadata: project.metadata,
221
+ name: project.name,
222
+ outputDir: this._absolutePath(project.outputDir),
223
+ repeatEach: project.repeatEach,
224
+ retries: project.retries,
225
+ testDir: this._absolutePath(project.testDir),
226
+ testIgnore: parseRegexPatterns(project.testIgnore),
227
+ testMatch: parseRegexPatterns(project.testMatch),
228
+ timeout: project.timeout,
229
+ grep: parseRegexPatterns(project.grep),
230
+ grepInvert: parseRegexPatterns(project.grepInvert),
231
+ dependencies: project.dependencies,
232
+ teardown: project.teardown,
233
+ snapshotDir: this._absolutePath(project.snapshotDir),
234
+ use: project.use
235
+ };
236
+ }
237
+ _parseAttachments(attachments) {
238
+ return attachments.map((a) => {
239
+ return {
240
+ ...a,
241
+ body: a.base64 && globalThis.Buffer ? Buffer.from(a.base64, "base64") : void 0
242
+ };
243
+ });
244
+ }
245
+ _mergeSuiteInto(jsonSuite, parent) {
246
+ let targetSuite = parent.suites.find((s) => s.title === jsonSuite.title);
247
+ if (!targetSuite) {
248
+ targetSuite = new TeleSuite(jsonSuite.title, parent.type === "project" ? "file" : "describe");
249
+ parent._addSuite(targetSuite);
250
+ }
251
+ targetSuite.location = this._absoluteLocation(jsonSuite.location);
252
+ jsonSuite.entries.forEach((e) => {
253
+ if ("testId" in e)
254
+ this._mergeTestInto(e, targetSuite);
255
+ else
256
+ this._mergeSuiteInto(e, targetSuite);
257
+ });
258
+ }
259
+ _mergeTestInto(jsonTest, parent) {
260
+ let targetTest = this._options.mergeTestCases ? parent.tests.find((s) => s.title === jsonTest.title && s.repeatEachIndex === jsonTest.repeatEachIndex) : void 0;
261
+ if (!targetTest) {
262
+ targetTest = new TeleTestCase(jsonTest.testId, jsonTest.title, this._absoluteLocation(jsonTest.location), jsonTest.repeatEachIndex);
263
+ parent._addTest(targetTest);
264
+ this._tests.set(targetTest.id, targetTest);
265
+ }
266
+ this._updateTest(jsonTest, targetTest);
267
+ }
268
+ _updateTest(payload, test) {
269
+ test.id = payload.testId;
270
+ test.location = this._absoluteLocation(payload.location);
271
+ test.retries = payload.retries;
272
+ test.tags = payload.tags ?? [];
273
+ test.annotations = payload.annotations ?? [];
274
+ this._absoluteAnnotationLocationsInplace(test.annotations);
275
+ return test;
276
+ }
277
+ _absoluteAnnotationLocationsInplace(annotations) {
278
+ for (const annotation of annotations) {
279
+ if (annotation.location)
280
+ annotation.location = this._absoluteLocation(annotation.location);
281
+ }
282
+ }
283
+ _absoluteLocation(location) {
284
+ if (!location)
285
+ return location;
286
+ return {
287
+ ...location,
288
+ file: this._absolutePath(location.file)
289
+ };
290
+ }
291
+ _absolutePath(relativePath) {
292
+ if (relativePath === void 0)
293
+ return;
294
+ return this._options.resolvePath ? this._options.resolvePath(this._rootDir, relativePath) : this._rootDir + "/" + relativePath;
295
+ }
296
+ }
297
+ class TeleSuite {
298
+ constructor(title, type) {
299
+ this._entries = [];
300
+ this._requireFile = "";
301
+ this._parallelMode = "none";
302
+ this.title = title;
303
+ this._type = type;
304
+ }
305
+ get type() {
306
+ return this._type;
307
+ }
308
+ get suites() {
309
+ return this._entries.filter((e) => e.type !== "test");
310
+ }
311
+ get tests() {
312
+ return this._entries.filter((e) => e.type === "test");
313
+ }
314
+ entries() {
315
+ return this._entries;
316
+ }
317
+ allTests() {
318
+ const result = [];
319
+ const visit = (suite) => {
320
+ for (const entry of suite.entries()) {
321
+ if (entry.type === "test")
322
+ result.push(entry);
323
+ else
324
+ visit(entry);
325
+ }
326
+ };
327
+ visit(this);
328
+ return result;
329
+ }
330
+ titlePath() {
331
+ const titlePath = this.parent ? this.parent.titlePath() : [];
332
+ if (this.title || this._type !== "describe")
333
+ titlePath.push(this.title);
334
+ return titlePath;
335
+ }
336
+ project() {
337
+ return this._project ?? this.parent?.project();
338
+ }
339
+ _addTest(test) {
340
+ test.parent = this;
341
+ this._entries.push(test);
342
+ }
343
+ _addSuite(suite) {
344
+ suite.parent = this;
345
+ this._entries.push(suite);
346
+ }
347
+ }
348
+ class TeleTestCase {
349
+ constructor(id, title, location, repeatEachIndex) {
350
+ this.fn = () => {
351
+ };
352
+ this.results = [];
353
+ this.type = "test";
354
+ this.expectedStatus = "passed";
355
+ this.timeout = 0;
356
+ this.annotations = [];
357
+ this.retries = 0;
358
+ this.tags = [];
359
+ this.repeatEachIndex = 0;
360
+ this.id = id;
361
+ this.title = title;
362
+ this.location = location;
363
+ this.repeatEachIndex = repeatEachIndex;
364
+ }
365
+ titlePath() {
366
+ const titlePath = this.parent ? this.parent.titlePath() : [];
367
+ titlePath.push(this.title);
368
+ return titlePath;
369
+ }
370
+ outcome() {
371
+ return computeTestCaseOutcome(this);
372
+ }
373
+ ok() {
374
+ const status = this.outcome();
375
+ return status === "expected" || status === "flaky" || status === "skipped";
376
+ }
377
+ _createTestResult(id) {
378
+ const result = new TeleTestResult(this.results.length, id);
379
+ this.results.push(result);
380
+ return result;
381
+ }
382
+ }
383
+ class TeleTestStep {
384
+ constructor(payload, parentStep, location, result) {
385
+ this.duration = -1;
386
+ this.steps = [];
387
+ this._startTime = 0;
388
+ this.title = payload.title;
389
+ this.category = payload.category;
390
+ this.location = location;
391
+ this.parent = parentStep;
392
+ this._startTime = payload.startTime;
393
+ this._result = result;
394
+ }
395
+ titlePath() {
396
+ const parentPath = this.parent?.titlePath() || [];
397
+ return [...parentPath, this.title];
398
+ }
399
+ get startTime() {
400
+ return new Date(this._startTime);
401
+ }
402
+ set startTime(value) {
403
+ this._startTime = +value;
404
+ }
405
+ get attachments() {
406
+ return this._endPayload?.attachments?.map((index) => this._result.attachments[index]) ?? [];
407
+ }
408
+ get annotations() {
409
+ return this._endPayload?.annotations ?? [];
410
+ }
411
+ }
412
+ class TeleTestResult {
413
+ constructor(retry, id) {
414
+ this.parallelIndex = -1;
415
+ this.workerIndex = -1;
416
+ this.shardIndex = -1;
417
+ this.duration = -1;
418
+ this.stdout = [];
419
+ this.stderr = [];
420
+ this.attachments = [];
421
+ this.annotations = [];
422
+ this.status = "skipped";
423
+ this.steps = [];
424
+ this.errors = [];
425
+ this._stepMap = /* @__PURE__ */ new Map();
426
+ this._startTime = 0;
427
+ this.retry = retry;
428
+ this._id = id;
429
+ }
430
+ setStartTimeNumber(startTime) {
431
+ this._startTime = startTime;
432
+ }
433
+ get startTime() {
434
+ return new Date(this._startTime);
435
+ }
436
+ set startTime(value) {
437
+ this._startTime = +value;
438
+ }
439
+ }
440
+ const baseFullConfig = {
441
+ forbidOnly: false,
442
+ fullyParallel: false,
443
+ globalSetup: null,
444
+ globalTeardown: null,
445
+ globalTimeout: 0,
446
+ grep: /.*/,
447
+ grepInvert: null,
448
+ maxFailures: 0,
449
+ metadata: {},
450
+ preserveOutput: "always",
451
+ projects: [],
452
+ reporter: [[process.env.CI ? "dot" : "list"]],
453
+ reportSlowTests: {
454
+ max: 5,
455
+ threshold: 3e5
456
+ /* 5 minutes */
457
+ },
458
+ configFile: "",
459
+ rootDir: "",
460
+ quiet: false,
461
+ shard: null,
462
+ tags: [],
463
+ updateSnapshots: "missing",
464
+ updateSourceMethod: "patch",
465
+ runAgents: "none",
466
+ version: "",
467
+ workers: 0,
468
+ webServer: null
469
+ };
470
+ function serializeRegexPatterns(patterns) {
471
+ if (!Array.isArray(patterns))
472
+ patterns = [patterns];
473
+ return patterns.map((s) => {
474
+ if (typeof s === "string")
475
+ return { s };
476
+ return { r: { source: s.source, flags: s.flags } };
477
+ });
478
+ }
479
+ function parseRegexPatterns(patterns) {
480
+ return patterns.map((p) => {
481
+ if (p.s !== void 0)
482
+ return p.s;
483
+ return new RegExp(p.r.source, p.r.flags);
484
+ });
485
+ }
486
+ function computeTestCaseOutcome(test) {
487
+ let skipped = 0;
488
+ let didNotRun = 0;
489
+ let expected = 0;
490
+ let interrupted = 0;
491
+ let unexpected = 0;
492
+ for (const result of test.results) {
493
+ if (result.status === "interrupted") {
494
+ ++interrupted;
495
+ } else if (result.status === "skipped" && test.expectedStatus === "skipped") {
496
+ ++skipped;
497
+ } else if (result.status === "skipped") {
498
+ ++didNotRun;
499
+ } else if (result.status === test.expectedStatus) {
500
+ ++expected;
501
+ } else {
502
+ ++unexpected;
503
+ }
504
+ }
505
+ if (expected === 0 && unexpected === 0)
506
+ return "skipped";
507
+ if (unexpected === 0)
508
+ return "expected";
509
+ if (expected === 0 && skipped === 0)
510
+ return "unexpected";
511
+ return "flaky";
512
+ }
513
+ // Annotate the CommonJS export names for ESM import in node:
514
+ 0 && (module.exports = {
515
+ TeleReporterReceiver,
516
+ TeleSuite,
517
+ TeleTestCase,
518
+ TeleTestResult,
519
+ baseFullConfig,
520
+ computeTestCaseOutcome,
521
+ parseRegexPatterns,
522
+ serializeRegexPatterns
523
+ });
@@ -0,0 +1,157 @@
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 teleSuiteUpdater_exports = {};
20
+ __export(teleSuiteUpdater_exports, {
21
+ TeleSuiteUpdater: () => TeleSuiteUpdater
22
+ });
23
+ module.exports = __toCommonJS(teleSuiteUpdater_exports);
24
+ var import_teleReceiver = require("./teleReceiver");
25
+ var import_testTree = require("./testTree");
26
+ class TeleSuiteUpdater {
27
+ constructor(options) {
28
+ this.loadErrors = [];
29
+ this.progress = {
30
+ total: 0,
31
+ passed: 0,
32
+ failed: 0,
33
+ skipped: 0
34
+ };
35
+ this._lastRunTestCount = 0;
36
+ this._receiver = new import_teleReceiver.TeleReporterReceiver(this._createReporter(), {
37
+ mergeProjects: true,
38
+ mergeTestCases: true,
39
+ resolvePath: createPathResolve(options.pathSeparator),
40
+ clearPreviousResultsWhenTestBegins: true
41
+ });
42
+ this._options = options;
43
+ }
44
+ _createReporter() {
45
+ return {
46
+ version: () => "v2",
47
+ onConfigure: (config) => {
48
+ this.config = config;
49
+ this._lastRunReceiver = new import_teleReceiver.TeleReporterReceiver({
50
+ version: () => "v2",
51
+ onBegin: (suite) => {
52
+ this._lastRunTestCount = suite.allTests().length;
53
+ this._lastRunReceiver = void 0;
54
+ }
55
+ }, {
56
+ mergeProjects: true,
57
+ mergeTestCases: false,
58
+ resolvePath: createPathResolve(this._options.pathSeparator)
59
+ });
60
+ void this._lastRunReceiver.dispatch({ method: "onConfigure", params: { config } });
61
+ },
62
+ onBegin: (suite) => {
63
+ if (!this.rootSuite)
64
+ this.rootSuite = suite;
65
+ if (this._testResultsSnapshot) {
66
+ for (const test of this.rootSuite.allTests())
67
+ test.results = this._testResultsSnapshot?.get(test.id) || test.results;
68
+ this._testResultsSnapshot = void 0;
69
+ }
70
+ this.progress.total = this._lastRunTestCount;
71
+ this.progress.passed = 0;
72
+ this.progress.failed = 0;
73
+ this.progress.skipped = 0;
74
+ this._options.onUpdate(true);
75
+ },
76
+ onEnd: () => {
77
+ this._options.onUpdate(true);
78
+ },
79
+ onTestBegin: (test, testResult) => {
80
+ testResult[import_testTree.statusEx] = "running";
81
+ this._options.onUpdate();
82
+ },
83
+ onTestEnd: (test, testResult) => {
84
+ if (test.outcome() === "skipped")
85
+ ++this.progress.skipped;
86
+ else if (test.outcome() === "unexpected")
87
+ ++this.progress.failed;
88
+ else
89
+ ++this.progress.passed;
90
+ testResult[import_testTree.statusEx] = testResult.status;
91
+ this._options.onUpdate();
92
+ },
93
+ onError: (error) => this._handleOnError(error),
94
+ printsToStdio: () => false
95
+ };
96
+ }
97
+ processGlobalReport(report) {
98
+ const receiver = new import_teleReceiver.TeleReporterReceiver({
99
+ version: () => "v2",
100
+ onConfigure: (c) => {
101
+ this.config = c;
102
+ },
103
+ onError: (error) => this._handleOnError(error)
104
+ });
105
+ for (const message of report)
106
+ void receiver.dispatch(message);
107
+ }
108
+ processListReport(report) {
109
+ const tests = this.rootSuite?.allTests() || [];
110
+ this._testResultsSnapshot = new Map(tests.map((test) => [test.id, test.results]));
111
+ this._receiver.reset();
112
+ for (const message of report)
113
+ void this._receiver.dispatch(message);
114
+ }
115
+ processTestReportEvent(message) {
116
+ this._lastRunReceiver?.dispatch(message)?.catch(() => {
117
+ });
118
+ this._receiver.dispatch(message)?.catch(() => {
119
+ });
120
+ }
121
+ _handleOnError(error) {
122
+ this.loadErrors.push(error);
123
+ this._options.onError?.(error);
124
+ this._options.onUpdate();
125
+ }
126
+ asModel() {
127
+ return {
128
+ rootSuite: this.rootSuite || new import_teleReceiver.TeleSuite("", "root"),
129
+ config: this.config,
130
+ loadErrors: this.loadErrors,
131
+ progress: this.progress
132
+ };
133
+ }
134
+ }
135
+ function createPathResolve(pathSeparator) {
136
+ return (rootDir, relativePath) => {
137
+ const segments = [];
138
+ for (const segment of [...rootDir.split(pathSeparator), ...relativePath.split(pathSeparator)]) {
139
+ const isAfterDrive = pathSeparator === "\\" && segments.length === 1 && segments[0].endsWith(":");
140
+ const isFirst = !segments.length;
141
+ if (!segment && !isFirst && !isAfterDrive)
142
+ continue;
143
+ if (segment === ".")
144
+ continue;
145
+ if (segment === "..") {
146
+ segments.pop();
147
+ continue;
148
+ }
149
+ segments.push(segment);
150
+ }
151
+ return segments.join(pathSeparator);
152
+ };
153
+ }
154
+ // Annotate the CommonJS export names for ESM import in node:
155
+ 0 && (module.exports = {
156
+ TeleSuiteUpdater
157
+ });