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
@@ -28,9 +28,9 @@ var import_workerHost = require("./workerHost");
28
28
  var import_ipc = require("../common/ipc");
29
29
  var import_internalReporter = require("../reporters/internalReporter");
30
30
  var import_util = require("../util");
31
- var import_storage = require("./storage");
32
31
  class Dispatcher {
33
32
  constructor(config, reporter, failureTracker) {
33
+ // Worker slot is claimed when it has jobDispatcher assigned.
34
34
  this._workerSlots = [];
35
35
  this._queue = [];
36
36
  this._workerLimitPerProjectId = /* @__PURE__ */ new Map();
@@ -53,7 +53,7 @@ class Dispatcher {
53
53
  const projectIdWorkerLimit = this._workerLimitPerProjectId.get(job.projectId);
54
54
  if (!projectIdWorkerLimit)
55
55
  return index;
56
- const runningWorkersWithSameProjectId = this._workerSlots.filter((w) => w.busy && w.worker && w.worker.projectId() === job.projectId).length;
56
+ const runningWorkersWithSameProjectId = this._workerSlots.filter((w) => w.jobDispatcher?.job.projectId === job.projectId).length;
57
57
  if (runningWorkersWithSameProjectId < projectIdWorkerLimit)
58
58
  return index;
59
59
  }
@@ -66,20 +66,18 @@ class Dispatcher {
66
66
  if (jobIndex === -1)
67
67
  return;
68
68
  const job = this._queue[jobIndex];
69
- let workerIndex = this._workerSlots.findIndex((w) => !w.busy && w.worker && w.worker.hash() === job.workerHash && !w.worker.didSendStop());
69
+ let workerIndex = this._workerSlots.findIndex((w) => !w.jobDispatcher && w.worker && w.worker.hash() === job.workerHash && !w.worker.didSendStop());
70
70
  if (workerIndex === -1)
71
- workerIndex = this._workerSlots.findIndex((w) => !w.busy);
71
+ workerIndex = this._workerSlots.findIndex((w) => !w.jobDispatcher);
72
72
  if (workerIndex === -1) {
73
73
  return;
74
74
  }
75
75
  this._queue.splice(jobIndex, 1);
76
76
  const jobDispatcher = new JobDispatcher(job, this._config, this._reporter, this._failureTracker, () => this.stop().catch(() => {
77
77
  }));
78
- this._workerSlots[workerIndex].busy = true;
79
78
  this._workerSlots[workerIndex].jobDispatcher = jobDispatcher;
80
79
  void this._runJobInWorker(workerIndex, jobDispatcher).then(() => {
81
80
  this._workerSlots[workerIndex].jobDispatcher = void 0;
82
- this._workerSlots[workerIndex].busy = false;
83
81
  this._checkFinished();
84
82
  this._scheduleJob();
85
83
  });
@@ -127,7 +125,7 @@ class Dispatcher {
127
125
  return;
128
126
  if (this._queue.length && !this._isStopped)
129
127
  return;
130
- if (this._workerSlots.some((w) => w.busy))
128
+ if (this._workerSlots.some((w) => !!w.jobDispatcher))
131
129
  return;
132
130
  this._finished.resolve();
133
131
  }
@@ -152,7 +150,7 @@ class Dispatcher {
152
150
  if (this._failureTracker.hasReachedMaxFailures())
153
151
  void this.stop();
154
152
  for (let i = 0; i < this._config.config.workers; i++)
155
- this._workerSlots.push({ busy: false });
153
+ this._workerSlots.push({});
156
154
  for (let i = 0; i < this._workerSlots.length; i++)
157
155
  this._scheduleJob();
158
156
  this._checkFinished();
@@ -198,12 +196,6 @@ class Dispatcher {
198
196
  const producedEnv = this._producedEnvByProjectId.get(testGroup.projectId) || {};
199
197
  this._producedEnvByProjectId.set(testGroup.projectId, { ...producedEnv, ...worker.producedEnv() });
200
198
  });
201
- worker.onRequest("cloneStorage", async (params) => {
202
- return await import_storage.Storage.clone(params.storageFile, outputDir);
203
- });
204
- worker.onRequest("upstreamStorage", async (params) => {
205
- await import_storage.Storage.upstream(params.storageFile, params.storageOutFile);
206
- });
207
199
  return worker;
208
200
  }
209
201
  producedEnvByProjectId() {
@@ -52,7 +52,6 @@ async function collectProjectsAndTestFiles(testRun, doNotRunTestsOutsideProjectF
52
52
  const config = testRun.config;
53
53
  const fsCache = /* @__PURE__ */ new Map();
54
54
  const sourceMapCache = /* @__PURE__ */ new Map();
55
- const cliFileMatcher = config.cliArgs.length ? (0, import_util.createFileMatcherFromArguments)(config.cliArgs) : null;
56
55
  const allFilesForProject = /* @__PURE__ */ new Map();
57
56
  const filteredProjects = (0, import_projectUtils.filterProjects)(config.projects, config.cliProjectFilter);
58
57
  for (const project of filteredProjects) {
@@ -62,10 +61,12 @@ async function collectProjectsAndTestFiles(testRun, doNotRunTestsOutsideProjectF
62
61
  const filesToRunByProject = /* @__PURE__ */ new Map();
63
62
  for (const [project, files] of allFilesForProject) {
64
63
  const matchedFiles = files.filter((file) => {
65
- const hasMatchingSources = sourceMapSources(file, sourceMapCache).some((source) => {
66
- if (cliFileMatcher && !cliFileMatcher(source))
67
- return false;
64
+ if (!config.loadFileFilters.length) {
68
65
  return true;
66
+ }
67
+ const hasMatchingSources = sourceMapSources(file, sourceMapCache).some((source) => {
68
+ const matchesAllFileFilters = config.loadFileFilters.every((filter) => filter(source));
69
+ return matchesAllFileFilters;
69
70
  });
70
71
  return hasMatchingSources;
71
72
  });
@@ -310,7 +311,7 @@ async function loadTestList(config, filePath) {
310
311
  }
311
312
  return { project, file: (0, import_utils.toPosixPath)((0, import_util.parseLocationArg)(tokens[0]).file), titlePath: tokens.slice(1) };
312
313
  });
313
- return (test) => descriptions.some((d) => {
314
+ const testFilter = (test) => descriptions.some((d) => {
314
315
  const [projectName, , ...titles] = test.titlePath();
315
316
  if (d.project !== void 0 && d.project !== projectName)
316
317
  return false;
@@ -319,6 +320,11 @@ async function loadTestList(config, filePath) {
319
320
  return false;
320
321
  return d.titlePath.length <= titles.length && d.titlePath.every((_, index) => titles[index] === d.titlePath[index]);
321
322
  });
323
+ const fileFilter = (file) => {
324
+ const relativeFile = (0, import_utils.toPosixPath)(import_path.default.relative(config.config.rootDir, file));
325
+ return descriptions.some((d) => d.file === relativeFile);
326
+ };
327
+ return { testFilter, fileFilter };
322
328
  } catch (e) {
323
329
  throw (0, import_util.errorWithFile)(filePath, "Cannot read test list file: " + e.message);
324
330
  }
@@ -145,7 +145,7 @@ function buildDependentProjects(forProjects, projects) {
145
145
  return result;
146
146
  }
147
147
  async function collectFilesForProject(project, fsCache = /* @__PURE__ */ new Map()) {
148
- const extensions = /* @__PURE__ */ new Set([".js", ".ts", ".mjs", ".mts", ".cjs", ".cts", ".jsx", ".tsx", ".mjsx", ".mtsx", ".cjsx", ".ctsx", ".md"]);
148
+ const extensions = /* @__PURE__ */ new Set([".js", ".ts", ".mjs", ".mts", ".cjs", ".cts", ".jsx", ".tsx", ".mjsx", ".mtsx", ".cjsx", ".ctsx"]);
149
149
  const testFileExtension = (file) => extensions.has(import_path.default.extname(file));
150
150
  const allFiles = await cachedCollectFiles(project.project.testDir, project.respectGitIgnore, fsCache);
151
151
  const testMatch = (0, import_util2.createFileMatcher)(project.project.testMatch);
@@ -33,6 +33,7 @@ __export(reporters_exports, {
33
33
  createReporters: () => createReporters
34
34
  });
35
35
  module.exports = __toCommonJS(reporters_exports);
36
+ var import_fs = __toESM(require("fs"));
36
37
  var import_utils = require("patchright-bun-core/lib/utils");
37
38
  var import_loadUtils = require("./loadUtils");
38
39
  var import_base = require("../reporters/base");
@@ -126,6 +127,10 @@ function computeCommandHash(config) {
126
127
  command.cliOnlyChanged = config.cliOnlyChanged;
127
128
  if (config.config.tags.length)
128
129
  command.tags = config.config.tags.join(" ");
130
+ if (config.cliTestList)
131
+ command.cliTestList = (0, import_utils.calculateSha1)(import_fs.default.readFileSync(config.cliTestList));
132
+ if (config.cliTestListInvert)
133
+ command.cliTestListInvert = (0, import_utils.calculateSha1)(import_fs.default.readFileSync(config.cliTestListInvert));
129
134
  if (Object.keys(command).length)
130
135
  parts.push((0, import_utils.calculateSha1)(JSON.stringify(command)).substring(0, 7));
131
136
  return parts.join("-");
@@ -239,6 +239,17 @@ function createLoadTask(mode, options) {
239
239
  return {
240
240
  title: "load tests",
241
241
  setup: async (testRun, errors, softErrors) => {
242
+ if (testRun.config.cliArgs.length)
243
+ testRun.config.loadFileFilters.push((0, import_util2.createFileMatcherFromArguments)(testRun.config.cliArgs));
244
+ if (testRun.config.cliTestList) {
245
+ const { testFilter, fileFilter } = await (0, import_loadUtils.loadTestList)(testRun.config, testRun.config.cliTestList);
246
+ testRun.config.preOnlyTestFilters.push(testFilter);
247
+ testRun.config.loadFileFilters.push(fileFilter);
248
+ }
249
+ if (testRun.config.cliTestListInvert) {
250
+ const { testFilter } = await (0, import_loadUtils.loadTestList)(testRun.config, testRun.config.cliTestListInvert);
251
+ testRun.config.preOnlyTestFilters.push((test) => !testFilter(test));
252
+ }
242
253
  await (0, import_loadUtils.collectProjectsAndTestFiles)(testRun, !!options.doNotRunDepsOutsideProjectFilter);
243
254
  await (0, import_loadUtils.loadFileSuites)(testRun, mode, options.failOnLoadErrors ? errors : softErrors);
244
255
  if (testRun.config.cliOnlyChanged || options.populateDependencies) {
@@ -249,14 +260,6 @@ function createLoadTask(mode, options) {
249
260
  const changedFiles = await (0, import_vcs.detectChangedTestFiles)(testRun.config.cliOnlyChanged, testRun.config.configDir);
250
261
  testRun.config.preOnlyTestFilters.push((test) => changedFiles.has(test.location.file));
251
262
  }
252
- if (testRun.config.cliTestList) {
253
- const testListFilter = await (0, import_loadUtils.loadTestList)(testRun.config, testRun.config.cliTestList);
254
- testRun.config.preOnlyTestFilters.push(testListFilter);
255
- }
256
- if (testRun.config.cliTestListInvert) {
257
- const testListInvertFilter = await (0, import_loadUtils.loadTestList)(testRun.config, testRun.config.cliTestListInvert);
258
- testRun.config.preOnlyTestFilters.push((test) => !testListInvertFilter(test));
259
- }
260
263
  const { rootSuite, topLevelProjects } = await (0, import_loadUtils.createRootSuite)(testRun, options.failOnLoadErrors ? errors : softErrors, !!options.filterOnly);
261
264
  testRun.rootSuite = rootSuite;
262
265
  testRun.failureTracker.onRootSuite(rootSuite, topLevelProjects);
@@ -201,6 +201,7 @@ class TestRunner extends import_events.default {
201
201
  config.cliGrep = params.grep;
202
202
  config.cliGrepInvert = params.grepInvert;
203
203
  config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
204
+ config.cliOnlyChanged = params.onlyChanged;
204
205
  config.cliListOnly = true;
205
206
  const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
206
207
  (0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: false, filterOnly: false, populateDependencies: this._populateDependenciesOnList }),
@@ -248,7 +249,7 @@ class TestRunner extends import_events.default {
248
249
  reporter: params.reporters ? params.reporters.map((r) => [r]) : void 0,
249
250
  use: {
250
251
  ...this._configCLIOverrides.use,
251
- ...params.trace === "on" ? { trace: { mode: "on", sources: false, _live: true } } : {},
252
+ ...params.trace === "on" ? { trace: { mode: "on", sources: false, live: true } } : {},
252
253
  ...params.trace === "off" ? { trace: "off" } : {},
253
254
  ...params.video === "on" || params.video === "off" ? { video: params.video } : {},
254
255
  ...params.headed !== void 0 ? { headless: !params.headed } : {},
@@ -258,7 +259,6 @@ class TestRunner extends import_events.default {
258
259
  },
259
260
  ...params.updateSnapshots ? { updateSnapshots: params.updateSnapshots } : {},
260
261
  ...params.updateSourceMethod ? { updateSourceMethod: params.updateSourceMethod } : {},
261
- ...params.runAgents ? { runAgents: params.runAgents } : {},
262
262
  ...params.workers ? { workers: params.workers } : {}
263
263
  };
264
264
  const config = await this._loadConfigOrReportError(new import_internalReporter.InternalReporter([userReporter]), overrides);
@@ -61,9 +61,6 @@ class WorkerHost extends import_processHost.ProcessHost {
61
61
  pauseAtEnd: options.pauseAtEnd
62
62
  };
63
63
  }
64
- artifactsDir() {
65
- return this._params.artifactsDir;
66
- }
67
64
  async start() {
68
65
  await import_fs.default.promises.mkdir(this._params.artifactsDir, { recursive: true });
69
66
  return await this.startRunner(this._params, {
@@ -0,0 +1,220 @@
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 testActions_exports = {};
30
+ __export(testActions_exports, {
31
+ clearCache: () => clearCache,
32
+ runTestServerAction: () => runTestServerAction,
33
+ runTests: () => runTests,
34
+ startDevServer: () => startDevServer
35
+ });
36
+ module.exports = __toCommonJS(testActions_exports);
37
+ var import_fs = __toESM(require("fs"));
38
+ var import_path = __toESM(require("path"));
39
+ var import_utils = require("patchright-bun-core/lib/utils");
40
+ var import_config = require("./common/config");
41
+ var import_configLoader = require("./common/configLoader");
42
+ var import_base = require("./reporters/base");
43
+ var import_projectUtils = require("./runner/projectUtils");
44
+ var testServer = __toESM(require("./runner/testServer"));
45
+ var import_watchMode = require("./runner/watchMode");
46
+ var import_testRunner = require("./runner/testRunner");
47
+ var import_reporters = require("./runner/reporters");
48
+ async function runTests(args, opts) {
49
+ await (0, import_utils.startProfiling)();
50
+ const cliOverrides = overridesFromOptions(opts);
51
+ const config = await (0, import_configLoader.loadConfigFromFile)(opts.config, cliOverrides, opts.deps === false);
52
+ config.cliArgs = args;
53
+ config.cliGrep = opts.grep;
54
+ config.cliOnlyChanged = opts.onlyChanged === true ? "HEAD" : opts.onlyChanged;
55
+ config.cliGrepInvert = opts.grepInvert;
56
+ config.cliListOnly = !!opts.list;
57
+ config.cliProjectFilter = opts.project || void 0;
58
+ config.cliPassWithNoTests = !!opts.passWithNoTests;
59
+ config.cliLastFailed = !!opts.lastFailed;
60
+ config.cliTestList = opts.testList ? import_path.default.resolve(process.cwd(), opts.testList) : void 0;
61
+ config.cliTestListInvert = opts.testListInvert ? import_path.default.resolve(process.cwd(), opts.testListInvert) : void 0;
62
+ (0, import_projectUtils.filterProjects)(config.projects, config.cliProjectFilter);
63
+ if (opts.ui || opts.uiHost || opts.uiPort) {
64
+ if (opts.onlyChanged)
65
+ 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.`);
66
+ const status2 = await testServer.runUIMode(opts.config, cliOverrides, {
67
+ host: opts.uiHost,
68
+ port: opts.uiPort ? +opts.uiPort : void 0,
69
+ args,
70
+ grep: opts.grep,
71
+ grepInvert: opts.grepInvert,
72
+ project: opts.project || void 0,
73
+ reporter: Array.isArray(opts.reporter) ? opts.reporter : opts.reporter ? [opts.reporter] : void 0
74
+ });
75
+ await (0, import_utils.stopProfiling)("runner");
76
+ const exitCode2 = status2 === "interrupted" ? 130 : status2 === "passed" ? 0 : 1;
77
+ (0, import_utils.gracefullyProcessExitDoNotHang)(exitCode2);
78
+ return;
79
+ }
80
+ if (process.env.PWTEST_WATCH) {
81
+ if (opts.onlyChanged)
82
+ 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.`);
83
+ const status2 = await (0, import_watchMode.runWatchModeLoop)(
84
+ (0, import_configLoader.resolveConfigLocation)(opts.config),
85
+ {
86
+ projects: opts.project,
87
+ files: args,
88
+ grep: opts.grep
89
+ }
90
+ );
91
+ await (0, import_utils.stopProfiling)("runner");
92
+ const exitCode2 = status2 === "interrupted" ? 130 : status2 === "passed" ? 0 : 1;
93
+ (0, import_utils.gracefullyProcessExitDoNotHang)(exitCode2);
94
+ return;
95
+ }
96
+ const status = await (0, import_testRunner.runAllTestsWithConfig)(config);
97
+ await (0, import_utils.stopProfiling)("runner");
98
+ const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
99
+ (0, import_utils.gracefullyProcessExitDoNotHang)(exitCode);
100
+ }
101
+ async function runTestServerAction(opts) {
102
+ const host = opts.host;
103
+ const port = opts.port ? +opts.port : void 0;
104
+ const status = await testServer.runTestServer(opts.config, {}, { host, port });
105
+ const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
106
+ (0, import_utils.gracefullyProcessExitDoNotHang)(exitCode);
107
+ }
108
+ async function clearCache(opts) {
109
+ const runner = new import_testRunner.TestRunner((0, import_configLoader.resolveConfigLocation)(opts.config), {});
110
+ const { status } = await runner.clearCache((0, import_reporters.createErrorCollectingReporter)(import_base.terminalScreen));
111
+ const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
112
+ (0, import_utils.gracefullyProcessExitDoNotHang)(exitCode);
113
+ }
114
+ async function startDevServer(options) {
115
+ const runner = new import_testRunner.TestRunner((0, import_configLoader.resolveConfigLocation)(options.config), {});
116
+ await runner.startDevServer((0, import_reporters.createErrorCollectingReporter)(import_base.terminalScreen), "in-process");
117
+ }
118
+ function overridesFromOptions(options) {
119
+ if (options.ui) {
120
+ options.debug = void 0;
121
+ options.trace = void 0;
122
+ }
123
+ const overrides = {
124
+ debug: options.debug,
125
+ failOnFlakyTests: options.failOnFlakyTests ? true : void 0,
126
+ forbidOnly: options.forbidOnly ? true : void 0,
127
+ fullyParallel: options.fullyParallel ? true : void 0,
128
+ globalTimeout: options.globalTimeout ? parseInt(options.globalTimeout, 10) : void 0,
129
+ maxFailures: options.x ? 1 : options.maxFailures ? parseInt(options.maxFailures, 10) : void 0,
130
+ outputDir: options.output ? import_path.default.resolve(process.cwd(), options.output) : void 0,
131
+ pause: !!process.env.PWPAUSE,
132
+ quiet: options.quiet ? options.quiet : void 0,
133
+ repeatEach: options.repeatEach ? parseInt(options.repeatEach, 10) : void 0,
134
+ retries: options.retries ? parseInt(options.retries, 10) : void 0,
135
+ reporter: resolveReporterOption(options.reporter),
136
+ shard: resolveShardOption(options.shard),
137
+ shardWeights: resolveShardWeightsOption(),
138
+ timeout: options.timeout ? parseInt(options.timeout, 10) : void 0,
139
+ tsconfig: options.tsconfig ? import_path.default.resolve(process.cwd(), options.tsconfig) : void 0,
140
+ ignoreSnapshots: options.ignoreSnapshots ? !!options.ignoreSnapshots : void 0,
141
+ updateSnapshots: options.updateSnapshots,
142
+ updateSourceMethod: options.updateSourceMethod,
143
+ use: {
144
+ trace: options.trace
145
+ },
146
+ workers: options.workers
147
+ };
148
+ if (options.browser) {
149
+ const browserOpt = options.browser.toLowerCase();
150
+ if (!["all", "chromium", "firefox", "webkit"].includes(browserOpt))
151
+ throw new Error(`Unsupported browser "${options.browser}", must be one of "all", "chromium", "firefox" or "webkit"`);
152
+ const browserNames = browserOpt === "all" ? ["chromium", "firefox", "webkit"] : [browserOpt];
153
+ overrides.projects = browserNames.map((browserName) => {
154
+ return {
155
+ name: browserName,
156
+ use: { browserName }
157
+ };
158
+ });
159
+ }
160
+ if (options.headed)
161
+ overrides.use.headless = false;
162
+ if (options.debug === "inspector") {
163
+ overrides.use.headless = false;
164
+ process.env.PWDEBUG = "1";
165
+ }
166
+ if (overrides.tsconfig && !import_fs.default.existsSync(overrides.tsconfig))
167
+ throw new Error(`--tsconfig "${options.tsconfig}" does not exist`);
168
+ return overrides;
169
+ }
170
+ function resolveReporterOption(reporter) {
171
+ if (!reporter || !reporter.length)
172
+ return void 0;
173
+ return reporter.split(",").map((r) => [resolveReporter(r)]);
174
+ }
175
+ function resolveShardOption(shard) {
176
+ if (!shard)
177
+ return void 0;
178
+ const shardPair = shard.split("/");
179
+ if (shardPair.length !== 2) {
180
+ throw new Error(
181
+ `--shard "${shard}", expected format is "current/all", 1-based, for example "3/5".`
182
+ );
183
+ }
184
+ const current = parseInt(shardPair[0], 10);
185
+ const total = parseInt(shardPair[1], 10);
186
+ if (isNaN(total) || total < 1)
187
+ throw new Error(`--shard "${shard}" total must be a positive number`);
188
+ if (isNaN(current) || current < 1 || current > total) {
189
+ throw new Error(
190
+ `--shard "${shard}" current must be a positive number, not greater than shard total`
191
+ );
192
+ }
193
+ return { current, total };
194
+ }
195
+ function resolveShardWeightsOption() {
196
+ const shardWeights = process.env.PWTEST_SHARD_WEIGHTS;
197
+ if (!shardWeights)
198
+ return void 0;
199
+ return shardWeights.split(":").map((w) => {
200
+ const weight = parseInt(w, 10);
201
+ if (isNaN(weight) || weight < 0)
202
+ throw new Error(`PWTEST_SHARD_WEIGHTS="${shardWeights}" weights must be non-negative numbers`);
203
+ return weight;
204
+ });
205
+ }
206
+ function resolveReporter(id) {
207
+ if (import_config.builtInReporters.includes(id))
208
+ return id;
209
+ const localPath = import_path.default.resolve(process.cwd(), id);
210
+ if (import_fs.default.existsSync(localPath))
211
+ return localPath;
212
+ return require.resolve(id, { paths: [process.cwd()] });
213
+ }
214
+ // Annotate the CommonJS export names for ESM import in node:
215
+ 0 && (module.exports = {
216
+ clearCache,
217
+ runTestServerAction,
218
+ runTests,
219
+ startDevServer
220
+ });
@@ -22,7 +22,6 @@ __export(babelBundle_exports, {
22
22
  babelTransform: () => babelTransform,
23
23
  codeFrameColumns: () => codeFrameColumns,
24
24
  declare: () => declare,
25
- genMapping: () => genMapping,
26
25
  traverse: () => traverse,
27
26
  types: () => types
28
27
  });
@@ -33,14 +32,12 @@ const types = require("./babelBundleImpl").types;
33
32
  const traverse = require("./babelBundleImpl").traverse;
34
33
  const babelTransform = require("./babelBundleImpl").babelTransform;
35
34
  const babelParse = require("./babelBundleImpl").babelParse;
36
- const genMapping = require("./babelBundleImpl").genMapping;
37
35
  // Annotate the CommonJS export names for ESM import in node:
38
36
  0 && (module.exports = {
39
37
  babelParse,
40
38
  babelTransform,
41
39
  codeFrameColumns,
42
40
  declare,
43
- genMapping,
44
41
  traverse,
45
42
  types
46
43
  });