patchright-bun 1.58.2 → 1.59.0

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 (108) hide show
  1. package/ThirdPartyNotices.txt +10 -1133
  2. package/lib/agents/generateAgents.js +2 -4
  3. package/lib/common/config.js +4 -5
  4. package/lib/common/expectBundleImpl.js +221 -221
  5. package/lib/common/process.js +1 -0
  6. package/lib/common/test.js +10 -1
  7. package/lib/common/testType.js +3 -0
  8. package/lib/common/validators.js +38 -38
  9. package/lib/errorContext.js +121 -0
  10. package/lib/index.js +98 -60
  11. package/lib/isomorphic/teleReceiver.js +26 -9
  12. package/lib/isomorphic/testServerConnection.js +3 -5
  13. package/lib/matchers/matchers.js +2 -0
  14. package/lib/matchers/toMatchAriaSnapshot.js +5 -1
  15. package/lib/matchers/toMatchSnapshot.js +42 -35
  16. package/lib/mcp/test/browserBackend.js +45 -22
  17. package/lib/mcp/test/generatorTools.js +9 -9
  18. package/lib/mcp/test/plannerTools.js +17 -17
  19. package/lib/mcp/test/testBackend.js +27 -27
  20. package/lib/mcp/test/testContext.js +6 -8
  21. package/lib/mcp/test/testTools.js +9 -9
  22. package/lib/plugins/webServerPlugin.js +2 -1
  23. package/lib/program.js +34 -212
  24. package/lib/reportActions.js +80 -0
  25. package/lib/reporters/base.js +4 -5
  26. package/lib/reporters/blob.js +2 -2
  27. package/lib/reporters/github.js +1 -2
  28. package/lib/reporters/html.js +64 -31
  29. package/lib/reporters/junit.js +104 -15
  30. package/lib/reporters/line.js +1 -1
  31. package/lib/reporters/list.js +2 -3
  32. package/lib/reporters/merge.js +47 -26
  33. package/lib/reporters/multiplexer.js +6 -2
  34. package/lib/reporters/teleEmitter.js +2 -0
  35. package/lib/runner/dispatcher.js +6 -14
  36. package/lib/runner/loadUtils.js +11 -5
  37. package/lib/runner/projectUtils.js +1 -1
  38. package/lib/runner/reporters.js +5 -0
  39. package/lib/runner/tasks.js +11 -8
  40. package/lib/runner/testRunner.js +2 -2
  41. package/lib/runner/workerHost.js +0 -3
  42. package/lib/testActions.js +220 -0
  43. package/lib/transform/babelBundle.js +0 -3
  44. package/lib/transform/babelBundleImpl.js +134 -134
  45. package/lib/transform/compilationCache.js +0 -2
  46. package/lib/transform/esmLoader.js +8 -6
  47. package/lib/transform/transform.js +3 -10
  48. package/lib/utilsBundle.js +0 -7
  49. package/lib/utilsBundleImpl.js +48 -51
  50. package/lib/worker/fixtureRunner.js +2 -2
  51. package/lib/worker/testInfo.js +10 -14
  52. package/lib/worker/testTracing.js +12 -6
  53. package/lib/worker/timeoutManager.js +14 -3
  54. package/lib/worker/workerMain.js +24 -21
  55. package/package.json +2 -6
  56. package/types/test.d.ts +83 -12
  57. package/lib/mcp/browser/browserContextFactory.js +0 -329
  58. package/lib/mcp/browser/browserServerBackend.js +0 -84
  59. package/lib/mcp/browser/config.js +0 -421
  60. package/lib/mcp/browser/context.js +0 -244
  61. package/lib/mcp/browser/response.js +0 -278
  62. package/lib/mcp/browser/sessionLog.js +0 -75
  63. package/lib/mcp/browser/tab.js +0 -343
  64. package/lib/mcp/browser/tools/common.js +0 -65
  65. package/lib/mcp/browser/tools/console.js +0 -46
  66. package/lib/mcp/browser/tools/dialogs.js +0 -60
  67. package/lib/mcp/browser/tools/evaluate.js +0 -61
  68. package/lib/mcp/browser/tools/files.js +0 -58
  69. package/lib/mcp/browser/tools/form.js +0 -63
  70. package/lib/mcp/browser/tools/install.js +0 -72
  71. package/lib/mcp/browser/tools/keyboard.js +0 -107
  72. package/lib/mcp/browser/tools/mouse.js +0 -107
  73. package/lib/mcp/browser/tools/navigate.js +0 -71
  74. package/lib/mcp/browser/tools/network.js +0 -63
  75. package/lib/mcp/browser/tools/open.js +0 -57
  76. package/lib/mcp/browser/tools/pdf.js +0 -49
  77. package/lib/mcp/browser/tools/runCode.js +0 -78
  78. package/lib/mcp/browser/tools/screenshot.js +0 -93
  79. package/lib/mcp/browser/tools/snapshot.js +0 -173
  80. package/lib/mcp/browser/tools/tabs.js +0 -67
  81. package/lib/mcp/browser/tools/tool.js +0 -47
  82. package/lib/mcp/browser/tools/tracing.js +0 -74
  83. package/lib/mcp/browser/tools/utils.js +0 -94
  84. package/lib/mcp/browser/tools/verify.js +0 -143
  85. package/lib/mcp/browser/tools/wait.js +0 -63
  86. package/lib/mcp/browser/tools.js +0 -84
  87. package/lib/mcp/browser/watchdog.js +0 -44
  88. package/lib/mcp/config.d.js +0 -16
  89. package/lib/mcp/extension/cdpRelay.js +0 -351
  90. package/lib/mcp/extension/extensionContextFactory.js +0 -76
  91. package/lib/mcp/extension/protocol.js +0 -28
  92. package/lib/mcp/index.js +0 -61
  93. package/lib/mcp/log.js +0 -35
  94. package/lib/mcp/program.js +0 -111
  95. package/lib/mcp/sdk/exports.js +0 -28
  96. package/lib/mcp/sdk/http.js +0 -152
  97. package/lib/mcp/sdk/inProcessTransport.js +0 -71
  98. package/lib/mcp/sdk/server.js +0 -223
  99. package/lib/mcp/sdk/tool.js +0 -47
  100. package/lib/mcp/terminal/cli.js +0 -296
  101. package/lib/mcp/terminal/command.js +0 -56
  102. package/lib/mcp/terminal/commands.js +0 -333
  103. package/lib/mcp/terminal/daemon.js +0 -129
  104. package/lib/mcp/terminal/help.json +0 -32
  105. package/lib/mcp/terminal/helpGenerator.js +0 -88
  106. package/lib/mcp/terminal/socketConnection.js +0 -80
  107. package/lib/runner/storage.js +0 -91
  108. package/lib/transform/md.js +0 -221
package/lib/program.js CHANGED
@@ -31,26 +31,11 @@ __export(program_exports, {
31
31
  program: () => import_program2.program
32
32
  });
33
33
  module.exports = __toCommonJS(program_exports);
34
- var import_fs = __toESM(require("fs"));
35
- var import_path = __toESM(require("path"));
36
- var import_program = require("patchright-bun-core/lib/cli/program");
34
+ var import_bootstrap = require("patchright-bun-core/lib/bootstrap");
37
35
  var import_utils = require("patchright-bun-core/lib/utils");
36
+ var import_program = require("patchright-bun-core/lib/cli/program");
38
37
  var import_config = require("./common/config");
39
- var import_configLoader = require("./common/configLoader");
40
38
  var import_program2 = require("patchright-bun-core/lib/cli/program");
41
- var import_base = require("./reporters/base");
42
- var import_html = require("./reporters/html");
43
- var import_merge = require("./reporters/merge");
44
- var import_projectUtils = require("./runner/projectUtils");
45
- var testServer = __toESM(require("./runner/testServer"));
46
- var import_watchMode = require("./runner/watchMode");
47
- var import_testRunner = require("./runner/testRunner");
48
- var import_reporters = require("./runner/reporters");
49
- var mcp = __toESM(require("./mcp/sdk/exports"));
50
- var import_testBackend = require("./mcp/test/testBackend");
51
- var import_program3 = require("./mcp/program");
52
- var import_watchdog = require("./mcp/browser/watchdog");
53
- var import_generateAgents = require("./agents/generateAgents");
54
39
  const packageJSON = require("../package.json");
55
40
  function addTestCommand(program3) {
56
41
  const command = program3.command("test [test-filter...]");
@@ -67,6 +52,7 @@ function addTestCommand(program3) {
67
52
  });
68
53
  command.action(async (args, opts) => {
69
54
  try {
55
+ const { runTests } = require("./testActions");
70
56
  await runTests(args, opts);
71
57
  } catch (e) {
72
58
  console.error(e);
@@ -88,10 +74,8 @@ function addClearCacheCommand(program3) {
88
74
  command.description("clears build and test caches");
89
75
  command.option("-c, --config <file>", `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);
90
76
  command.action(async (opts) => {
91
- const runner = new import_testRunner.TestRunner((0, import_configLoader.resolveConfigLocation)(opts.config), {});
92
- const { status } = await runner.clearCache((0, import_reporters.createErrorCollectingReporter)(import_base.terminalScreen));
93
- const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
94
- (0, import_utils.gracefullyProcessExitDoNotHang)(exitCode);
77
+ const { clearCache } = require("./testActions");
78
+ await clearCache(opts);
95
79
  });
96
80
  }
97
81
  function addDevServerCommand(program3) {
@@ -99,8 +83,8 @@ function addDevServerCommand(program3) {
99
83
  command.description("start dev server");
100
84
  command.option("-c, --config <file>", `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);
101
85
  command.action(async (options) => {
102
- const runner = new import_testRunner.TestRunner((0, import_configLoader.resolveConfigLocation)(options.config), {});
103
- await runner.startDevServer((0, import_reporters.createErrorCollectingReporter)(import_base.terminalScreen), "in-process");
86
+ const { startDevServer } = require("./testActions");
87
+ await startDevServer(options);
104
88
  });
105
89
  }
106
90
  function addTestServerCommand(program3) {
@@ -109,12 +93,18 @@ function addTestServerCommand(program3) {
109
93
  command.option("-c, --config <file>", `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);
110
94
  command.option("--host <host>", "Host to start the server on", "localhost");
111
95
  command.option("--port <port>", "Port to start the server on", "0");
112
- command.action((opts) => runTestServer(opts));
96
+ command.action(async (opts) => {
97
+ const { runTestServerAction } = require("./testActions");
98
+ await runTestServerAction(opts);
99
+ });
113
100
  }
114
101
  function addShowReportCommand(program3) {
115
102
  const command = program3.command("show-report [report]");
116
103
  command.description("show HTML report");
117
- command.action((report, options) => (0, import_html.showHTMLReport)(report, options.host, +options.port));
104
+ command.action(async (report, options) => {
105
+ const { showReport } = require("./reportActions");
106
+ await showReport(report, options.host, +options.port);
107
+ });
118
108
  command.option("--host <host>", "Host to serve report on", "localhost");
119
109
  command.option("--port <port>", "Port to serve report on", "9323");
120
110
  command.addHelpText("afterAll", `
@@ -130,6 +120,7 @@ function addMergeReportsCommand(program3) {
130
120
  command.description("merge multiple blob reports (for sharded tests) into a single report");
131
121
  command.action(async (dir, options) => {
132
122
  try {
123
+ const { mergeReports } = require("./reportActions");
133
124
  await mergeReports(dir, options);
134
125
  } catch (e) {
135
126
  console.error(e);
@@ -145,11 +136,6 @@ Arguments [dir]:
145
136
  Examples:
146
137
  $ npx playwright merge-reports playwright-report`);
147
138
  }
148
- function addBrowserMCPServerCommand(program3) {
149
- const command = program3.command("run-mcp-server", { hidden: true });
150
- command.description("Interact with the browser over MCP");
151
- (0, import_program3.decorateCommand)(command, packageJSON.version);
152
- }
153
139
  function addTestMCPServerCommand(program3) {
154
140
  const command = program3.command("run-test-mcp-server", { hidden: true });
155
141
  command.description("Interact with the test runner over MCP");
@@ -158,14 +144,19 @@ function addTestMCPServerCommand(program3) {
158
144
  command.option("--host <host>", "host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.");
159
145
  command.option("--port <port>", "port to listen on for SSE transport.");
160
146
  command.action(async (options) => {
161
- (0, import_watchdog.setupExitWatchdog)();
147
+ const { start, setupExitWatchdog } = await import("playwright-core/lib/tools/exports");
148
+ const { TestServerBackend, testServerBackendTools } = require("./mcp/test/testBackend");
149
+ setupExitWatchdog();
162
150
  const factory = {
163
151
  name: "Playwright Test Runner",
164
152
  nameInConfig: "playwright-test-runner",
165
153
  version: packageJSON.version,
166
- create: () => new import_testBackend.TestServerBackend(options.config, { muteConsole: options.port === void 0, headless: options.headless })
154
+ toolSchemas: testServerBackendTools.map((tool) => tool.schema),
155
+ create: async () => new TestServerBackend(options.config, { muteConsole: options.port === void 0, headless: options.headless }),
156
+ disposed: async () => {
157
+ }
167
158
  };
168
- await mcp.start(factory, { port: options.port === void 0 ? void 0 : +options.port, host: options.host });
159
+ await start(factory, { port: options.port === void 0 ? void 0 : +options.port, host: options.host });
169
160
  });
170
161
  }
171
162
  function addInitAgentsCommand(program3) {
@@ -178,196 +169,27 @@ function addInitAgentsCommand(program3) {
178
169
  command.option("--project <project>", "Project to use for seed test");
179
170
  command.option("--prompts", "Whether to include prompts in the agent initialization");
180
171
  command.action(async (opts) => {
181
- const config = await (0, import_configLoader.loadConfigFromFile)(opts.config);
172
+ const { loadConfigFromFile } = require("./common/configLoader");
173
+ const { ClaudeGenerator, OpencodeGenerator, VSCodeGenerator, CopilotGenerator } = require("./agents/generateAgents");
174
+ const config = await loadConfigFromFile(opts.config);
182
175
  if (opts.loop === "opencode") {
183
- await import_generateAgents.OpencodeGenerator.init(config, opts.project, opts.prompts);
176
+ await OpencodeGenerator.init(config, opts.project, opts.prompts);
184
177
  } else if (opts.loop === "vscode-legacy") {
185
- await import_generateAgents.VSCodeGenerator.init(config, opts.project);
178
+ await VSCodeGenerator.init(config, opts.project);
186
179
  } else if (opts.loop === "claude") {
187
- await import_generateAgents.ClaudeGenerator.init(config, opts.project, opts.prompts);
180
+ await ClaudeGenerator.init(config, opts.project, opts.prompts);
188
181
  } else {
189
- await import_generateAgents.CopilotGenerator.init(config, opts.project, opts.prompts);
182
+ await CopilotGenerator.init(config, opts.project, opts.prompts);
190
183
  return;
191
184
  }
192
185
  });
193
186
  }
194
- async function runTests(args, opts) {
195
- await (0, import_utils.startProfiling)();
196
- const cliOverrides = overridesFromOptions(opts);
197
- const config = await (0, import_configLoader.loadConfigFromFile)(opts.config, cliOverrides, opts.deps === false);
198
- config.cliArgs = args;
199
- config.cliGrep = opts.grep;
200
- config.cliOnlyChanged = opts.onlyChanged === true ? "HEAD" : opts.onlyChanged;
201
- config.cliGrepInvert = opts.grepInvert;
202
- config.cliListOnly = !!opts.list;
203
- config.cliProjectFilter = opts.project || void 0;
204
- config.cliPassWithNoTests = !!opts.passWithNoTests;
205
- config.cliLastFailed = !!opts.lastFailed;
206
- config.cliTestList = opts.testList ? import_path.default.resolve(process.cwd(), opts.testList) : void 0;
207
- config.cliTestListInvert = opts.testListInvert ? import_path.default.resolve(process.cwd(), opts.testListInvert) : void 0;
208
- (0, import_projectUtils.filterProjects)(config.projects, config.cliProjectFilter);
209
- if (opts.ui || opts.uiHost || opts.uiPort) {
210
- if (opts.onlyChanged)
211
- throw new Error(`--only-changed is not supported in UI mode. If you'd like that to change, see https://github.com/microsoft/playwright/issues/15075 for more details.`);
212
- const status2 = await testServer.runUIMode(opts.config, cliOverrides, {
213
- host: opts.uiHost,
214
- port: opts.uiPort ? +opts.uiPort : void 0,
215
- args,
216
- grep: opts.grep,
217
- grepInvert: opts.grepInvert,
218
- project: opts.project || void 0,
219
- reporter: Array.isArray(opts.reporter) ? opts.reporter : opts.reporter ? [opts.reporter] : void 0
220
- });
221
- await (0, import_utils.stopProfiling)("runner");
222
- const exitCode2 = status2 === "interrupted" ? 130 : status2 === "passed" ? 0 : 1;
223
- (0, import_utils.gracefullyProcessExitDoNotHang)(exitCode2);
224
- return;
225
- }
226
- if (process.env.PWTEST_WATCH) {
227
- if (opts.onlyChanged)
228
- throw new Error(`--only-changed is not supported in watch mode. If you'd like that to change, file an issue and let us know about your usecase for it.`);
229
- const status2 = await (0, import_watchMode.runWatchModeLoop)(
230
- (0, import_configLoader.resolveConfigLocation)(opts.config),
231
- {
232
- projects: opts.project,
233
- files: args,
234
- grep: opts.grep
235
- }
236
- );
237
- await (0, import_utils.stopProfiling)("runner");
238
- const exitCode2 = status2 === "interrupted" ? 130 : status2 === "passed" ? 0 : 1;
239
- (0, import_utils.gracefullyProcessExitDoNotHang)(exitCode2);
240
- return;
241
- }
242
- const status = await (0, import_testRunner.runAllTestsWithConfig)(config);
243
- await (0, import_utils.stopProfiling)("runner");
244
- const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
245
- (0, import_utils.gracefullyProcessExitDoNotHang)(exitCode);
246
- }
247
- async function runTestServer(opts) {
248
- const host = opts.host;
249
- const port = opts.port ? +opts.port : void 0;
250
- const status = await testServer.runTestServer(opts.config, {}, { host, port });
251
- const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
252
- (0, import_utils.gracefullyProcessExitDoNotHang)(exitCode);
253
- }
254
- async function mergeReports(reportDir, opts) {
255
- const configFile = opts.config;
256
- const config = configFile ? await (0, import_configLoader.loadConfigFromFile)(configFile) : await (0, import_configLoader.loadEmptyConfigForMergeReports)();
257
- const dir = import_path.default.resolve(process.cwd(), reportDir || "");
258
- const dirStat = await import_fs.default.promises.stat(dir).catch((e) => null);
259
- if (!dirStat)
260
- throw new Error("Directory does not exist: " + dir);
261
- if (!dirStat.isDirectory())
262
- throw new Error(`"${dir}" is not a directory`);
263
- let reporterDescriptions = resolveReporterOption(opts.reporter);
264
- if (!reporterDescriptions && configFile)
265
- reporterDescriptions = config.config.reporter;
266
- if (!reporterDescriptions)
267
- reporterDescriptions = [[import_config.defaultReporter]];
268
- const rootDirOverride = configFile ? config.config.rootDir : void 0;
269
- await (0, import_merge.createMergedReport)(config, dir, reporterDescriptions, rootDirOverride);
270
- (0, import_utils.gracefullyProcessExitDoNotHang)(0);
271
- }
272
- function overridesFromOptions(options) {
273
- const overrides = {
274
- failOnFlakyTests: options.failOnFlakyTests ? true : void 0,
275
- forbidOnly: options.forbidOnly ? true : void 0,
276
- fullyParallel: options.fullyParallel ? true : void 0,
277
- globalTimeout: options.globalTimeout ? parseInt(options.globalTimeout, 10) : void 0,
278
- maxFailures: options.x ? 1 : options.maxFailures ? parseInt(options.maxFailures, 10) : void 0,
279
- outputDir: options.output ? import_path.default.resolve(process.cwd(), options.output) : void 0,
280
- quiet: options.quiet ? options.quiet : void 0,
281
- repeatEach: options.repeatEach ? parseInt(options.repeatEach, 10) : void 0,
282
- retries: options.retries ? parseInt(options.retries, 10) : void 0,
283
- reporter: resolveReporterOption(options.reporter),
284
- shard: resolveShardOption(options.shard),
285
- shardWeights: resolveShardWeightsOption(),
286
- timeout: options.timeout ? parseInt(options.timeout, 10) : void 0,
287
- tsconfig: options.tsconfig ? import_path.default.resolve(process.cwd(), options.tsconfig) : void 0,
288
- ignoreSnapshots: options.ignoreSnapshots ? !!options.ignoreSnapshots : void 0,
289
- updateSnapshots: options.updateSnapshots,
290
- updateSourceMethod: options.updateSourceMethod,
291
- runAgents: options.runAgents,
292
- workers: options.workers,
293
- pause: process.env.PWPAUSE ? true : void 0
294
- };
295
- if (options.browser) {
296
- const browserOpt = options.browser.toLowerCase();
297
- if (!["all", "chromium", "firefox", "webkit"].includes(browserOpt))
298
- throw new Error(`Unsupported browser "${options.browser}", must be one of "all", "chromium", "firefox" or "webkit"`);
299
- const browserNames = browserOpt === "all" ? ["chromium", "firefox", "webkit"] : [browserOpt];
300
- overrides.projects = browserNames.map((browserName) => {
301
- return {
302
- name: browserName,
303
- use: { browserName }
304
- };
305
- });
306
- }
307
- if (options.headed || options.debug || overrides.pause)
308
- overrides.use = { headless: false };
309
- if (!options.ui && options.debug) {
310
- overrides.debug = true;
311
- process.env.PWDEBUG = "1";
312
- }
313
- if (!options.ui && options.trace) {
314
- overrides.use = overrides.use || {};
315
- overrides.use.trace = options.trace;
316
- }
317
- if (overrides.tsconfig && !import_fs.default.existsSync(overrides.tsconfig))
318
- throw new Error(`--tsconfig "${options.tsconfig}" does not exist`);
319
- return overrides;
320
- }
321
- function resolveReporterOption(reporter) {
322
- if (!reporter || !reporter.length)
323
- return void 0;
324
- return reporter.split(",").map((r) => [resolveReporter(r)]);
325
- }
326
- function resolveShardOption(shard) {
327
- if (!shard)
328
- return void 0;
329
- const shardPair = shard.split("/");
330
- if (shardPair.length !== 2) {
331
- throw new Error(
332
- `--shard "${shard}", expected format is "current/all", 1-based, for example "3/5".`
333
- );
334
- }
335
- const current = parseInt(shardPair[0], 10);
336
- const total = parseInt(shardPair[1], 10);
337
- if (isNaN(total) || total < 1)
338
- throw new Error(`--shard "${shard}" total must be a positive number`);
339
- if (isNaN(current) || current < 1 || current > total) {
340
- throw new Error(
341
- `--shard "${shard}" current must be a positive number, not greater than shard total`
342
- );
343
- }
344
- return { current, total };
345
- }
346
- function resolveShardWeightsOption() {
347
- const shardWeights = process.env.PWTEST_SHARD_WEIGHTS;
348
- if (!shardWeights)
349
- return void 0;
350
- return shardWeights.split(":").map((w) => {
351
- const weight = parseInt(w, 10);
352
- if (isNaN(weight) || weight < 0)
353
- throw new Error(`PWTEST_SHARD_WEIGHTS="${shardWeights}" weights must be non-negative numbers`);
354
- return weight;
355
- });
356
- }
357
- function resolveReporter(id) {
358
- if (import_config.builtInReporters.includes(id))
359
- return id;
360
- const localPath = import_path.default.resolve(process.cwd(), id);
361
- if (import_fs.default.existsSync(localPath))
362
- return localPath;
363
- return require.resolve(id, { paths: [process.cwd()] });
364
- }
365
- const kTraceModes = ["on", "off", "on-first-retry", "on-all-retries", "retain-on-failure", "retain-on-first-failure"];
187
+ const kTraceModes = ["on", "off", "on-first-retry", "on-all-retries", "retain-on-failure", "retain-on-first-failure", "retain-on-failure-and-retries"];
366
188
  const testOptions = [
367
189
  /* deprecated */
368
190
  ["--browser <browser>", { description: `Browser to use for tests, one of "all", "chromium", "firefox" or "webkit" (default: "chromium")` }],
369
191
  ["-c, --config <file>", { description: `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"` }],
370
- ["--debug", { description: `Run tests with Playwright Inspector. Shortcut for "PWDEBUG=1" environment variable and "--timeout=0 --max-failures=1 --headed --workers=1" options` }],
192
+ ["--debug [mode]", { description: `Run tests with Playwright Inspector. Shortcut for "PWDEBUG=1" environment variable and "--timeout=0 --max-failures=1 --headed --workers=1" options`, choices: ["inspector", "cli"], preset: "inspector" }],
371
193
  ["--fail-on-flaky-tests", { description: `Fail if any test is flagged as flaky (default: false)` }],
372
194
  ["--forbid-only", { description: `Fail if test.only is called (default: false)` }],
373
195
  ["--fully-parallel", { description: `Run all tests in parallel (default: false)` }],
@@ -388,6 +210,7 @@ const testOptions = [
388
210
  ["--repeat-each <N>", { description: `Run each test N times (default: 1)` }],
389
211
  ["--reporter <reporter>", { description: `Reporter to use, comma-separated, can be ${import_config.builtInReporters.map((name) => `"${name}"`).join(", ")} (default: "${import_config.defaultReporter}")` }],
390
212
  ["--retries <retries>", { description: `Maximum retry count for flaky tests, zero for no retries (default: no retries)` }],
213
+ ["--run-agents <mode>", { description: `Run agents to generate the code for page.perform`, choices: ["missing", "all", "none"], preset: "none" }],
391
214
  ["--shard <shard>", { description: `Shard tests and execute only the selected shard, specify in the form "current/all", 1-based, for example "3/5"` }],
392
215
  ["--test-list <file>", { description: `Path to a file containing a list of tests to run. See https://playwright.dev/docs/test-cli for more details.` }],
393
216
  ["--test-list-invert <file>", { description: `Path to a file containing a list of tests to skip. See https://playwright.dev/docs/test-cli for more details.` }],
@@ -406,7 +229,6 @@ addTestCommand(import_program.program);
406
229
  addShowReportCommand(import_program.program);
407
230
  addMergeReportsCommand(import_program.program);
408
231
  addClearCacheCommand(import_program.program);
409
- addBrowserMCPServerCommand(import_program.program);
410
232
  addTestMCPServerCommand(import_program.program);
411
233
  addDevServerCommand(import_program.program);
412
234
  addTestServerCommand(import_program.program);
@@ -0,0 +1,80 @@
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 reportActions_exports = {};
30
+ __export(reportActions_exports, {
31
+ mergeReports: () => mergeReports,
32
+ showReport: () => showReport
33
+ });
34
+ module.exports = __toCommonJS(reportActions_exports);
35
+ var import_fs = __toESM(require("fs"));
36
+ var import_path = __toESM(require("path"));
37
+ var import_utils = require("patchright-bun-core/lib/utils");
38
+ var import_config = require("./common/config");
39
+ var import_configLoader = require("./common/configLoader");
40
+ var import_html = require("./reporters/html");
41
+ var import_merge = require("./reporters/merge");
42
+ async function showReport(report, host, port) {
43
+ await (0, import_html.showHTMLReport)(report, host, port);
44
+ }
45
+ async function mergeReports(reportDir, opts) {
46
+ const configFile = opts.config;
47
+ const config = configFile ? await (0, import_configLoader.loadConfigFromFile)(configFile) : await (0, import_configLoader.loadEmptyConfigForMergeReports)();
48
+ const dir = import_path.default.resolve(process.cwd(), reportDir || "");
49
+ const dirStat = await import_fs.default.promises.stat(dir).catch((e) => null);
50
+ if (!dirStat)
51
+ throw new Error("Directory does not exist: " + dir);
52
+ if (!dirStat.isDirectory())
53
+ throw new Error(`"${dir}" is not a directory`);
54
+ let reporterDescriptions = resolveReporterOption(opts.reporter);
55
+ if (!reporterDescriptions && configFile)
56
+ reporterDescriptions = config.config.reporter;
57
+ if (!reporterDescriptions)
58
+ reporterDescriptions = [[import_config.defaultReporter]];
59
+ const rootDirOverride = configFile ? config.config.rootDir : void 0;
60
+ await (0, import_merge.createMergedReport)(config, dir, reporterDescriptions, rootDirOverride);
61
+ (0, import_utils.gracefullyProcessExitDoNotHang)(0);
62
+ }
63
+ function resolveReporterOption(reporter) {
64
+ if (!reporter || !reporter.length)
65
+ return void 0;
66
+ return reporter.split(",").map((r) => [resolveReporter(r)]);
67
+ }
68
+ function resolveReporter(id) {
69
+ if (import_config.builtInReporters.includes(id))
70
+ return id;
71
+ const localPath = import_path.default.resolve(process.cwd(), id);
72
+ if (import_fs.default.existsSync(localPath))
73
+ return localPath;
74
+ return require.resolve(id, { paths: [process.cwd()] });
75
+ }
76
+ // Annotate the CommonJS export names for ESM import in node:
77
+ 0 && (module.exports = {
78
+ mergeReports,
79
+ showReport
80
+ });
@@ -48,10 +48,9 @@ __export(base_exports, {
48
48
  module.exports = __toCommonJS(base_exports);
49
49
  var import_path = __toESM(require("path"));
50
50
  var import_utils = require("patchright-bun-core/lib/utils");
51
- var import_utilsBundle = require("patchright-bun-core/lib/utilsBundle");
52
51
  var import_utils2 = require("patchright-bun-core/lib/utils");
53
52
  var import_util = require("../util");
54
- var import_utilsBundle2 = require("../utilsBundle");
53
+ var import_utilsBundle = require("../utilsBundle");
55
54
  const kOutputSymbol = Symbol("output");
56
55
  const DEFAULT_TTY_WIDTH = 100;
57
56
  const DEFAULT_TTY_HEIGHT = 40;
@@ -206,7 +205,7 @@ class TerminalReporter {
206
205
  if (didNotRun)
207
206
  tokens.push(this.screen.colors.yellow(` ${didNotRun} did not run`));
208
207
  if (expected)
209
- tokens.push(this.screen.colors.green(` ${expected} passed`) + this.screen.colors.dim(` (${(0, import_utilsBundle.ms)(this.result.duration)})`));
208
+ tokens.push(this.screen.colors.green(` ${expected} passed`) + this.screen.colors.dim(` (${(0, import_utils.msToString)(this.result.duration)})`));
210
209
  if (fatalErrors.length && expected + unexpected.length + interrupted.length + flaky.length > 0)
211
210
  tokens.push(this.screen.colors.red(` ${fatalErrors.length === 1 ? "1 error was not a part of any test" : fatalErrors.length + " errors were not a part of any test"}, see above for details`));
212
211
  return tokens.join("\n");
@@ -273,7 +272,7 @@ class TerminalReporter {
273
272
  _printSlowTests() {
274
273
  const slowTests = this.getSlowTests();
275
274
  slowTests.forEach(([file, duration]) => {
276
- this.writeLine(this.screen.colors.yellow(" Slow test file: ") + file + this.screen.colors.yellow(` (${(0, import_utilsBundle.ms)(duration)})`));
275
+ this.writeLine(this.screen.colors.yellow(" Slow test file: ") + file + this.screen.colors.yellow(` (${(0, import_utils.msToString)(duration)})`));
277
276
  });
278
277
  if (slowTests.length)
279
278
  this.writeLine(this.screen.colors.yellow(" Consider running tests from slow files in parallel. See: https://playwright.dev/docs/test-parallel"));
@@ -514,7 +513,7 @@ function prepareErrorStack(stack) {
514
513
  return (0, import_utils.parseErrorStack)(stack, import_path.default.sep, !!process.env.PWDEBUGIMPL);
515
514
  }
516
515
  function characterWidth(c) {
517
- return import_utilsBundle2.getEastAsianWidth.eastAsianWidth(c.codePointAt(0));
516
+ return import_utilsBundle.getEastAsianWidth.eastAsianWidth(c.codePointAt(0));
518
517
  }
519
518
  function stringWidth(v) {
520
519
  let width = 0;
@@ -38,7 +38,6 @@ var import_stream = require("stream");
38
38
  var import_utils = require("patchright-bun-core/lib/utils");
39
39
  var import_utils2 = require("patchright-bun-core/lib/utils");
40
40
  var import_utilsBundle = require("patchright-bun-core/lib/utilsBundle");
41
- var import_zipBundle = require("patchright-bun-core/lib/zipBundle");
42
41
  var import_base = require("./base");
43
42
  var import_teleEmitter = require("./teleEmitter");
44
43
  const currentBlobReportVersion = 2;
@@ -73,7 +72,8 @@ class BlobReporter extends import_teleEmitter.TeleReporterEmitter {
73
72
  async onEnd(result) {
74
73
  await super.onEnd(result);
75
74
  const zipFileName = await this._prepareOutputFile();
76
- const zipFile = new import_zipBundle.yazl.ZipFile();
75
+ const { yazl } = await import("playwright-core/lib/zipBundle");
76
+ const zipFile = new yazl.ZipFile();
77
77
  const zipFinishPromise = new import_utils2.ManualPromise();
78
78
  const finishPromise = zipFinishPromise.catch((e) => {
79
79
  throw new Error(`Failed to write report ${zipFileName}: ` + e.message);
@@ -34,7 +34,6 @@ __export(github_exports, {
34
34
  module.exports = __toCommonJS(github_exports);
35
35
  var import_path = __toESM(require("path"));
36
36
  var import_utils = require("patchright-bun-core/lib/utils");
37
- var import_utilsBundle = require("patchright-bun-core/lib/utilsBundle");
38
37
  var import_base = require("./base");
39
38
  var import_util = require("../util");
40
39
  class GitHubLogger {
@@ -85,7 +84,7 @@ class GitHubReporter extends import_base.TerminalReporter {
85
84
  _printSlowTestAnnotations() {
86
85
  this.getSlowTests().forEach(([file, duration]) => {
87
86
  const filePath = workspaceRelativePath(import_path.default.join(process.cwd(), file));
88
- this.githubLogger.warning(`${filePath} took ${(0, import_utilsBundle.ms)(duration)}`, {
87
+ this.githubLogger.warning(`${filePath} took ${(0, import_utils.msToString)(duration)}`, {
89
88
  title: "Slow Test",
90
89
  file: filePath
91
90
  });