@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,546 @@
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 merge_exports = {};
30
+ __export(merge_exports, {
31
+ createMergedReport: () => createMergedReport
32
+ });
33
+ module.exports = __toCommonJS(merge_exports);
34
+ var import_fs = __toESM(require("fs"));
35
+ var import_path = __toESM(require("path"));
36
+ var import_utils = require("playwright-core/lib/utils");
37
+ var import_blob = require("./blob");
38
+ var import_multiplexer = require("./multiplexer");
39
+ var import_stringInternPool = require("../isomorphic/stringInternPool");
40
+ var import_teleReceiver = require("../isomorphic/teleReceiver");
41
+ var import_reporters = require("../runner/reporters");
42
+ var import_util = require("../util");
43
+ async function createMergedReport(config, dir, reporterDescriptions, rootDirOverride) {
44
+ const reporters = await (0, import_reporters.createReporters)(config, "merge", reporterDescriptions);
45
+ const multiplexer = new import_multiplexer.Multiplexer(reporters);
46
+ const stringPool = new import_stringInternPool.StringInternPool();
47
+ let printStatus = () => {
48
+ };
49
+ if (!multiplexer.printsToStdio()) {
50
+ printStatus = printStatusToStdout;
51
+ printStatus(`merging reports from ${dir}`);
52
+ }
53
+ const shardFiles = await sortedShardFiles(dir);
54
+ if (shardFiles.length === 0)
55
+ throw new Error(`No report files found in ${dir}`);
56
+ const eventData = await mergeEvents(dir, shardFiles, stringPool, printStatus, rootDirOverride);
57
+ const pathSeparator = rootDirOverride ? import_path.default.sep : eventData.pathSeparatorFromMetadata ?? import_path.default.sep;
58
+ const pathPackage = pathSeparator === "/" ? import_path.default.posix : import_path.default.win32;
59
+ const receiver = new import_teleReceiver.TeleReporterReceiver(multiplexer, {
60
+ mergeProjects: false,
61
+ mergeTestCases: false,
62
+ // When merging on a different OS, an absolute path like `C:\foo\bar` from win may look like
63
+ // a relative path on posix, and vice versa.
64
+ // Therefore, we cannot use `path.resolve()` here - it will resolve relative-looking paths
65
+ // against `process.cwd()`, while we just want to normalize ".." and "." segments.
66
+ resolvePath: (rootDir, relativePath) => stringPool.internString(pathPackage.normalize(pathPackage.join(rootDir, relativePath))),
67
+ configOverrides: config.config
68
+ });
69
+ printStatus(`processing test events`);
70
+ const dispatchEvents = async (events) => {
71
+ for (const event of events) {
72
+ if (event.method === "onEnd")
73
+ printStatus(`building final report`);
74
+ await receiver.dispatch(event);
75
+ if (event.method === "onEnd")
76
+ printStatus(`finished building report`);
77
+ }
78
+ };
79
+ await dispatchEvents(eventData.prologue);
80
+ for (const { reportFile, eventPatchers, metadata, tags } of eventData.reports) {
81
+ const reportJsonl = await import_fs.default.promises.readFile(reportFile);
82
+ const events = parseTestEvents(reportJsonl);
83
+ new import_stringInternPool.JsonStringInternalizer(stringPool).traverse(events);
84
+ eventPatchers.patchers.push(new AttachmentPathPatcher(dir));
85
+ if (metadata.name)
86
+ eventPatchers.patchers.push(new GlobalErrorPatcher(metadata.name));
87
+ if (tags.length)
88
+ eventPatchers.patchers.push(new GlobalErrorPatcher(tags.join(" ")));
89
+ eventPatchers.patchEvents(events);
90
+ await dispatchEvents(events);
91
+ }
92
+ await dispatchEvents(eventData.epilogue);
93
+ }
94
+ const commonEventNames = ["onBlobReportMetadata", "onConfigure", "onProject", "onBegin", "onEnd"];
95
+ const commonEvents = new Set(commonEventNames);
96
+ const commonEventRegex = new RegExp(`${commonEventNames.join("|")}`);
97
+ function parseCommonEvents(reportJsonl) {
98
+ return splitBufferLines(reportJsonl).map((line) => line.toString("utf8")).filter((line) => commonEventRegex.test(line)).map((line) => JSON.parse(line)).filter((event) => commonEvents.has(event.method));
99
+ }
100
+ function parseTestEvents(reportJsonl) {
101
+ return splitBufferLines(reportJsonl).map((line) => line.toString("utf8")).filter((line) => line.length).map((line) => JSON.parse(line)).filter((event) => !commonEvents.has(event.method));
102
+ }
103
+ function splitBufferLines(buffer) {
104
+ const lines = [];
105
+ let start = 0;
106
+ while (start < buffer.length) {
107
+ const end = buffer.indexOf(10, start);
108
+ if (end === -1) {
109
+ lines.push(buffer.slice(start));
110
+ break;
111
+ }
112
+ lines.push(buffer.slice(start, end));
113
+ start = end + 1;
114
+ }
115
+ return lines;
116
+ }
117
+ async function extractAndParseReports(dir, shardFiles, internalizer, printStatus) {
118
+ const shardEvents = [];
119
+ await import_fs.default.promises.mkdir(import_path.default.join(dir, "resources"), { recursive: true });
120
+ const reportNames = new UniqueFileNameGenerator();
121
+ for (const file of shardFiles) {
122
+ const absolutePath = import_path.default.join(dir, file);
123
+ printStatus(`extracting: ${(0, import_util.relativeFilePath)(absolutePath)}`);
124
+ const zipFile = new import_utils.ZipFile(absolutePath);
125
+ const entryNames = await zipFile.entries();
126
+ for (const entryName of entryNames.sort()) {
127
+ let fileName = import_path.default.join(dir, entryName);
128
+ const content = await zipFile.read(entryName);
129
+ if (entryName.endsWith(".jsonl")) {
130
+ fileName = reportNames.makeUnique(fileName);
131
+ let parsedEvents = parseCommonEvents(content);
132
+ internalizer.traverse(parsedEvents);
133
+ const metadata = findMetadata(parsedEvents, file);
134
+ parsedEvents = modernizer.modernize(metadata.version, parsedEvents);
135
+ shardEvents.push({
136
+ file,
137
+ localPath: fileName,
138
+ metadata,
139
+ parsedEvents
140
+ });
141
+ }
142
+ await import_fs.default.promises.writeFile(fileName, content);
143
+ }
144
+ zipFile.close();
145
+ }
146
+ return shardEvents;
147
+ }
148
+ function findMetadata(events, file) {
149
+ if (events[0]?.method !== "onBlobReportMetadata")
150
+ throw new Error(`No metadata event found in ${file}`);
151
+ const metadata = events[0].params;
152
+ if (metadata.version > import_blob.currentBlobReportVersion)
153
+ throw new Error(`Blob report ${file} was created with a newer version of Playwright.`);
154
+ return metadata;
155
+ }
156
+ async function mergeEvents(dir, shardReportFiles, stringPool, printStatus, rootDirOverride) {
157
+ const internalizer = new import_stringInternPool.JsonStringInternalizer(stringPool);
158
+ const configureEvents = [];
159
+ const projectEvents = [];
160
+ const endEvents = [];
161
+ const blobs = await extractAndParseReports(dir, shardReportFiles, internalizer, printStatus);
162
+ blobs.sort((a, b) => {
163
+ const nameA = a.metadata.name ?? "";
164
+ const nameB = b.metadata.name ?? "";
165
+ if (nameA !== nameB)
166
+ return nameA.localeCompare(nameB);
167
+ const shardA = a.metadata.shard?.current ?? 0;
168
+ const shardB = b.metadata.shard?.current ?? 0;
169
+ if (shardA !== shardB)
170
+ return shardA - shardB;
171
+ return a.file.localeCompare(b.file);
172
+ });
173
+ printStatus(`merging events`);
174
+ const reports = [];
175
+ const globalTestIdSet = /* @__PURE__ */ new Set();
176
+ for (let i = 0; i < blobs.length; ++i) {
177
+ const { parsedEvents, metadata, localPath } = blobs[i];
178
+ const eventPatchers = new JsonEventPatchers();
179
+ eventPatchers.patchers.push(new IdsPatcher(
180
+ stringPool,
181
+ metadata.name,
182
+ String(i),
183
+ globalTestIdSet
184
+ ));
185
+ if (rootDirOverride)
186
+ eventPatchers.patchers.push(new PathSeparatorPatcher(metadata.pathSeparator));
187
+ eventPatchers.patchEvents(parsedEvents);
188
+ let tags = [];
189
+ for (const event of parsedEvents) {
190
+ if (event.method === "onConfigure") {
191
+ configureEvents.push(event);
192
+ tags = event.params.config.tags || [];
193
+ } else if (event.method === "onProject") {
194
+ projectEvents.push(event);
195
+ } else if (event.method === "onEnd") {
196
+ endEvents.push(event);
197
+ }
198
+ }
199
+ reports.push({
200
+ eventPatchers,
201
+ reportFile: localPath,
202
+ metadata,
203
+ tags
204
+ });
205
+ }
206
+ return {
207
+ prologue: [
208
+ mergeConfigureEvents(configureEvents, rootDirOverride),
209
+ ...projectEvents,
210
+ { method: "onBegin", params: void 0 }
211
+ ],
212
+ reports,
213
+ epilogue: [
214
+ mergeEndEvents(endEvents),
215
+ { method: "onExit", params: void 0 }
216
+ ],
217
+ pathSeparatorFromMetadata: blobs[0]?.metadata.pathSeparator
218
+ };
219
+ }
220
+ function mergeConfigureEvents(configureEvents, rootDirOverride) {
221
+ if (!configureEvents.length)
222
+ throw new Error("No configure events found");
223
+ let config = {
224
+ configFile: void 0,
225
+ globalTimeout: 0,
226
+ maxFailures: 0,
227
+ metadata: {},
228
+ rootDir: "",
229
+ version: "",
230
+ workers: 0,
231
+ globalSetup: null,
232
+ globalTeardown: null
233
+ };
234
+ for (const event of configureEvents)
235
+ config = mergeConfigs(config, event.params.config);
236
+ if (rootDirOverride) {
237
+ config.rootDir = rootDirOverride;
238
+ } else {
239
+ const rootDirs = new Set(configureEvents.map((e) => e.params.config.rootDir));
240
+ if (rootDirs.size > 1) {
241
+ throw new Error([
242
+ `Blob reports being merged were recorded with different test directories, and`,
243
+ `merging cannot proceed. This may happen if you are merging reports from`,
244
+ `machines with different environments, like different operating systems or`,
245
+ `if the tests ran with different playwright configs.`,
246
+ ``,
247
+ `You can force merge by specifying a merge config file with "-c" option. If`,
248
+ `you'd like all test paths to be correct, make sure 'testDir' in the merge config`,
249
+ `file points to the actual tests location.`,
250
+ ``,
251
+ `Found directories:`,
252
+ ...rootDirs
253
+ ].join("\n"));
254
+ }
255
+ }
256
+ return {
257
+ method: "onConfigure",
258
+ params: {
259
+ config
260
+ }
261
+ };
262
+ }
263
+ function mergeConfigs(to, from) {
264
+ return {
265
+ ...to,
266
+ ...from,
267
+ metadata: {
268
+ ...to.metadata,
269
+ ...from.metadata,
270
+ actualWorkers: (to.metadata.actualWorkers || 0) + (from.metadata.actualWorkers || 0)
271
+ },
272
+ workers: to.workers + from.workers
273
+ };
274
+ }
275
+ function mergeEndEvents(endEvents) {
276
+ let startTime = endEvents.length ? 1e13 : Date.now();
277
+ let status = "passed";
278
+ let endTime = 0;
279
+ for (const event of endEvents) {
280
+ const shardResult = event.params.result;
281
+ if (shardResult.status === "failed")
282
+ status = "failed";
283
+ else if (shardResult.status === "timedout" && status !== "failed")
284
+ status = "timedout";
285
+ else if (shardResult.status === "interrupted" && status !== "failed" && status !== "timedout")
286
+ status = "interrupted";
287
+ startTime = Math.min(startTime, shardResult.startTime);
288
+ endTime = Math.max(endTime, shardResult.startTime + shardResult.duration);
289
+ }
290
+ const result = {
291
+ status,
292
+ startTime,
293
+ duration: endTime - startTime
294
+ };
295
+ return {
296
+ method: "onEnd",
297
+ params: {
298
+ result
299
+ }
300
+ };
301
+ }
302
+ async function sortedShardFiles(dir) {
303
+ const files = await import_fs.default.promises.readdir(dir);
304
+ return files.filter((file) => file.endsWith(".zip")).sort();
305
+ }
306
+ function printStatusToStdout(message) {
307
+ process.stdout.write(`${message}
308
+ `);
309
+ }
310
+ class UniqueFileNameGenerator {
311
+ constructor() {
312
+ this._usedNames = /* @__PURE__ */ new Set();
313
+ }
314
+ makeUnique(name) {
315
+ if (!this._usedNames.has(name)) {
316
+ this._usedNames.add(name);
317
+ return name;
318
+ }
319
+ const extension = import_path.default.extname(name);
320
+ name = name.substring(0, name.length - extension.length);
321
+ let index = 0;
322
+ while (true) {
323
+ const candidate = `${name}-${++index}${extension}`;
324
+ if (!this._usedNames.has(candidate)) {
325
+ this._usedNames.add(candidate);
326
+ return candidate;
327
+ }
328
+ }
329
+ }
330
+ }
331
+ class IdsPatcher {
332
+ constructor(stringPool, botName, salt, globalTestIdSet) {
333
+ this._stringPool = stringPool;
334
+ this._botName = botName;
335
+ this._salt = salt;
336
+ this._testIdsMap = /* @__PURE__ */ new Map();
337
+ this._globalTestIdSet = globalTestIdSet;
338
+ }
339
+ patchEvent(event) {
340
+ const { method, params } = event;
341
+ switch (method) {
342
+ case "onProject":
343
+ this._onProject(params.project);
344
+ return;
345
+ case "onAttach":
346
+ case "onTestBegin":
347
+ case "onStepBegin":
348
+ case "onStepEnd":
349
+ case "onStdIO":
350
+ params.testId = params.testId ? this._mapTestId(params.testId) : void 0;
351
+ return;
352
+ case "onTestEnd":
353
+ params.test.testId = this._mapTestId(params.test.testId);
354
+ return;
355
+ }
356
+ }
357
+ _onProject(project) {
358
+ project.metadata ??= {};
359
+ project.suites.forEach((suite) => this._updateTestIds(suite));
360
+ }
361
+ _updateTestIds(suite) {
362
+ suite.entries.forEach((entry) => {
363
+ if ("testId" in entry)
364
+ this._updateTestId(entry);
365
+ else
366
+ this._updateTestIds(entry);
367
+ });
368
+ }
369
+ _updateTestId(test) {
370
+ test.testId = this._mapTestId(test.testId);
371
+ if (this._botName) {
372
+ test.tags = test.tags || [];
373
+ test.tags.unshift("@" + this._botName);
374
+ }
375
+ }
376
+ _mapTestId(testId) {
377
+ const t1 = this._stringPool.internString(testId);
378
+ if (this._testIdsMap.has(t1))
379
+ return this._testIdsMap.get(t1);
380
+ if (this._globalTestIdSet.has(t1)) {
381
+ const t2 = this._stringPool.internString(testId + this._salt);
382
+ this._globalTestIdSet.add(t2);
383
+ this._testIdsMap.set(t1, t2);
384
+ return t2;
385
+ }
386
+ this._globalTestIdSet.add(t1);
387
+ this._testIdsMap.set(t1, t1);
388
+ return t1;
389
+ }
390
+ }
391
+ class AttachmentPathPatcher {
392
+ constructor(_resourceDir) {
393
+ this._resourceDir = _resourceDir;
394
+ }
395
+ patchEvent(event) {
396
+ if (event.method === "onAttach")
397
+ this._patchAttachments(event.params.attachments);
398
+ else if (event.method === "onTestEnd")
399
+ this._patchAttachments(event.params.result.attachments ?? []);
400
+ }
401
+ _patchAttachments(attachments) {
402
+ for (const attachment of attachments) {
403
+ if (!attachment.path)
404
+ continue;
405
+ attachment.path = import_path.default.join(this._resourceDir, attachment.path);
406
+ }
407
+ }
408
+ }
409
+ class PathSeparatorPatcher {
410
+ constructor(from) {
411
+ this._from = from ?? (import_path.default.sep === "/" ? "\\" : "/");
412
+ this._to = import_path.default.sep;
413
+ }
414
+ patchEvent(jsonEvent) {
415
+ if (this._from === this._to)
416
+ return;
417
+ if (jsonEvent.method === "onProject") {
418
+ this._updateProject(jsonEvent.params.project);
419
+ return;
420
+ }
421
+ if (jsonEvent.method === "onTestEnd") {
422
+ const test = jsonEvent.params.test;
423
+ test.annotations?.forEach((annotation) => this._updateAnnotationLocation(annotation));
424
+ const testResult = jsonEvent.params.result;
425
+ testResult.annotations?.forEach((annotation) => this._updateAnnotationLocation(annotation));
426
+ testResult.errors.forEach((error) => this._updateErrorLocations(error));
427
+ (testResult.attachments ?? []).forEach((attachment) => {
428
+ if (attachment.path)
429
+ attachment.path = this._updatePath(attachment.path);
430
+ });
431
+ return;
432
+ }
433
+ if (jsonEvent.method === "onStepBegin") {
434
+ const step = jsonEvent.params.step;
435
+ this._updateLocation(step.location);
436
+ return;
437
+ }
438
+ if (jsonEvent.method === "onStepEnd") {
439
+ const step = jsonEvent.params.step;
440
+ this._updateErrorLocations(step.error);
441
+ step.annotations?.forEach((annotation) => this._updateAnnotationLocation(annotation));
442
+ return;
443
+ }
444
+ if (jsonEvent.method === "onAttach") {
445
+ const attach = jsonEvent.params;
446
+ attach.attachments.forEach((attachment) => {
447
+ if (attachment.path)
448
+ attachment.path = this._updatePath(attachment.path);
449
+ });
450
+ return;
451
+ }
452
+ }
453
+ _updateProject(project) {
454
+ project.outputDir = this._updatePath(project.outputDir);
455
+ project.testDir = this._updatePath(project.testDir);
456
+ project.snapshotDir = this._updatePath(project.snapshotDir);
457
+ project.suites.forEach((suite) => this._updateSuite(suite, true));
458
+ }
459
+ _updateSuite(suite, isFileSuite = false) {
460
+ this._updateLocation(suite.location);
461
+ if (isFileSuite)
462
+ suite.title = this._updatePath(suite.title);
463
+ for (const entry of suite.entries) {
464
+ if ("testId" in entry) {
465
+ this._updateLocation(entry.location);
466
+ entry.annotations?.forEach((annotation) => this._updateAnnotationLocation(annotation));
467
+ } else {
468
+ this._updateSuite(entry);
469
+ }
470
+ }
471
+ }
472
+ _updateErrorLocations(error) {
473
+ while (error) {
474
+ this._updateLocation(error.location);
475
+ error = error.cause;
476
+ }
477
+ }
478
+ _updateAnnotationLocation(annotation) {
479
+ this._updateLocation(annotation.location);
480
+ }
481
+ _updateLocation(location) {
482
+ if (location)
483
+ location.file = this._updatePath(location.file);
484
+ }
485
+ _updatePath(text) {
486
+ return text.split(this._from).join(this._to);
487
+ }
488
+ }
489
+ class GlobalErrorPatcher {
490
+ constructor(botName) {
491
+ this._prefix = `(${botName}) `;
492
+ }
493
+ patchEvent(event) {
494
+ if (event.method !== "onError")
495
+ return;
496
+ const error = event.params.error;
497
+ if (error.message !== void 0)
498
+ error.message = this._prefix + error.message;
499
+ if (error.stack !== void 0)
500
+ error.stack = this._prefix + error.stack;
501
+ }
502
+ }
503
+ class JsonEventPatchers {
504
+ constructor() {
505
+ this.patchers = [];
506
+ }
507
+ patchEvents(events) {
508
+ for (const event of events) {
509
+ for (const patcher of this.patchers)
510
+ patcher.patchEvent(event);
511
+ }
512
+ }
513
+ }
514
+ class BlobModernizer {
515
+ modernize(fromVersion, events) {
516
+ const result = [];
517
+ for (const event of events)
518
+ result.push(...this._modernize(fromVersion, event));
519
+ return result;
520
+ }
521
+ _modernize(fromVersion, event) {
522
+ let events = [event];
523
+ for (let version = fromVersion; version < import_blob.currentBlobReportVersion; ++version)
524
+ events = this[`_modernize_${version}_to_${version + 1}`].call(this, events);
525
+ return events;
526
+ }
527
+ _modernize_1_to_2(events) {
528
+ return events.map((event) => {
529
+ if (event.method === "onProject") {
530
+ const modernizeSuite = (suite) => {
531
+ const newSuites = suite.suites.map(modernizeSuite);
532
+ const { suites, tests, ...remainder } = suite;
533
+ return { entries: [...newSuites, ...tests], ...remainder };
534
+ };
535
+ const project = event.params.project;
536
+ project.suites = project.suites.map(modernizeSuite);
537
+ }
538
+ return event;
539
+ });
540
+ }
541
+ }
542
+ const modernizer = new BlobModernizer();
543
+ // Annotate the CommonJS export names for ESM import in node:
544
+ 0 && (module.exports = {
545
+ createMergedReport
546
+ });
@@ -0,0 +1,112 @@
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 multiplexer_exports = {};
20
+ __export(multiplexer_exports, {
21
+ Multiplexer: () => Multiplexer
22
+ });
23
+ module.exports = __toCommonJS(multiplexer_exports);
24
+ class Multiplexer {
25
+ constructor(reporters) {
26
+ this._reporters = reporters;
27
+ }
28
+ version() {
29
+ return "v2";
30
+ }
31
+ onConfigure(config) {
32
+ for (const reporter of this._reporters)
33
+ wrap(() => reporter.onConfigure?.(config));
34
+ }
35
+ onBegin(suite) {
36
+ for (const reporter of this._reporters)
37
+ wrap(() => reporter.onBegin?.(suite));
38
+ }
39
+ onTestBegin(test, result) {
40
+ for (const reporter of this._reporters)
41
+ wrap(() => reporter.onTestBegin?.(test, result));
42
+ }
43
+ onStdOut(chunk, test, result) {
44
+ for (const reporter of this._reporters)
45
+ wrap(() => reporter.onStdOut?.(chunk, test, result));
46
+ }
47
+ onStdErr(chunk, test, result) {
48
+ for (const reporter of this._reporters)
49
+ wrap(() => reporter.onStdErr?.(chunk, test, result));
50
+ }
51
+ async onTestPaused(test, result, step) {
52
+ for (const reporter of this._reporters) {
53
+ const disposition = await wrapAsync(() => reporter.onTestPaused?.(test, result, step));
54
+ if (disposition?.action)
55
+ return disposition;
56
+ }
57
+ return { action: void 0 };
58
+ }
59
+ onTestEnd(test, result) {
60
+ for (const reporter of this._reporters)
61
+ wrap(() => reporter.onTestEnd?.(test, result));
62
+ }
63
+ async onEnd(result) {
64
+ for (const reporter of this._reporters) {
65
+ const outResult = await wrapAsync(() => reporter.onEnd?.(result));
66
+ if (outResult?.status)
67
+ result.status = outResult.status;
68
+ }
69
+ return result;
70
+ }
71
+ async onExit() {
72
+ for (const reporter of this._reporters)
73
+ await wrapAsync(() => reporter.onExit?.());
74
+ }
75
+ onError(error) {
76
+ for (const reporter of this._reporters)
77
+ wrap(() => reporter.onError?.(error));
78
+ }
79
+ onStepBegin(test, result, step) {
80
+ for (const reporter of this._reporters)
81
+ wrap(() => reporter.onStepBegin?.(test, result, step));
82
+ }
83
+ onStepEnd(test, result, step) {
84
+ for (const reporter of this._reporters)
85
+ wrap(() => reporter.onStepEnd?.(test, result, step));
86
+ }
87
+ printsToStdio() {
88
+ return this._reporters.some((r) => {
89
+ let prints = false;
90
+ wrap(() => prints = r.printsToStdio ? r.printsToStdio() : true);
91
+ return prints;
92
+ });
93
+ }
94
+ }
95
+ async function wrapAsync(callback) {
96
+ try {
97
+ return await callback();
98
+ } catch (e) {
99
+ console.error("Error in reporter", e);
100
+ }
101
+ }
102
+ function wrap(callback) {
103
+ try {
104
+ callback();
105
+ } catch (e) {
106
+ console.error("Error in reporter", e);
107
+ }
108
+ }
109
+ // Annotate the CommonJS export names for ESM import in node:
110
+ 0 && (module.exports = {
111
+ Multiplexer
112
+ });