playwright 1.58.0-alpha-2025-12-23 → 1.58.0-alpha-1766484475000

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.
package/lib/program.js CHANGED
@@ -282,6 +282,7 @@ function overridesFromOptions(options) {
282
282
  retries: options.retries ? parseInt(options.retries, 10) : void 0,
283
283
  reporter: resolveReporterOption(options.reporter),
284
284
  shard: resolveShardOption(options.shard),
285
+ shardWeights: resolveShardWeightsOption(options.shardWeights),
285
286
  timeout: options.timeout ? parseInt(options.timeout, 10) : void 0,
286
287
  tsconfig: options.tsconfig ? import_path.default.resolve(process.cwd(), options.tsconfig) : void 0,
287
288
  ignoreSnapshots: options.ignoreSnapshots ? !!options.ignoreSnapshots : void 0,
@@ -341,6 +342,16 @@ function resolveShardOption(shard) {
341
342
  }
342
343
  return { current, total };
343
344
  }
345
+ function resolveShardWeightsOption(shardWeights) {
346
+ if (!shardWeights)
347
+ return void 0;
348
+ return shardWeights.split(":").map((w) => {
349
+ const weight = parseInt(w, 10);
350
+ if (isNaN(weight) || weight < 0)
351
+ throw new Error(`--shard-weights "${shardWeights}" weights must be non-negative numbers`);
352
+ return weight;
353
+ });
354
+ }
344
355
  function resolveReporter(id) {
345
356
  if (import_config.builtInReporters.includes(id))
346
357
  return id;
@@ -377,6 +388,7 @@ const testOptions = [
377
388
  ["--retries <retries>", { description: `Maximum retry count for flaky tests, zero for no retries (default: no retries)` }],
378
389
  ["--run-agents", { description: `Run agents to generate the code for page.perform` }],
379
390
  ["--shard <shard>", { description: `Shard tests and execute only the selected shard, specify in the form "current/all", 1-based, for example "3/5"` }],
391
+ ["--shard-weights <weights>", { description: `Weights for each shard, colon-separated, for example "2:1:1" for 3 shards where the first shard should be allocated half of the work` }],
380
392
  ["--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.` }],
381
393
  ["--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.` }],
382
394
  ["--timeout <timeout>", { description: `Specify test timeout threshold in milliseconds, zero for unlimited (default: ${import_config.defaultTimeout})` }],
@@ -162,7 +162,7 @@ async function createRootSuite(testRun, errors, shouldFilterOnly) {
162
162
  for (const group of (0, import_testGroups.createTestGroups)(projectSuite, config.config.shard.total))
163
163
  testGroups.push(group);
164
164
  }
165
- const testGroupsInThisShard = (0, import_testGroups.filterForShard)(config.config.shard, testGroups);
165
+ const testGroupsInThisShard = (0, import_testGroups.filterForShard)(config.config.shard, config.configCLIOverrides.shardWeights, testGroups);
166
166
  const testsInThisShard = /* @__PURE__ */ new Set();
167
167
  for (const group of testGroupsInThisShard) {
168
168
  for (const test of group.tests)
@@ -92,15 +92,23 @@ function createTestGroups(projectSuite, expectedParallelism) {
92
92
  }
93
93
  return result;
94
94
  }
95
- function filterForShard(shard, testGroups) {
95
+ function filterForShard(shard, weights, testGroups) {
96
+ weights ??= Array.from({ length: shard.total }, () => 1);
97
+ if (weights.length !== shard.total)
98
+ throw new Error(`--shard-weights number of weights must match the shard total of ${shard.total}`);
99
+ const totalWeight = weights.reduce((a, b) => a + b, 0);
96
100
  let shardableTotal = 0;
97
101
  for (const group of testGroups)
98
102
  shardableTotal += group.tests.length;
99
- const shardSize = Math.floor(shardableTotal / shard.total);
100
- const extraOne = shardableTotal - shardSize * shard.total;
101
- const currentShard = shard.current - 1;
102
- const from = shardSize * currentShard + Math.min(extraOne, currentShard);
103
- const to = from + shardSize + (currentShard < extraOne ? 1 : 0);
103
+ const shardSizes = weights.map((w) => Math.floor(w * shardableTotal / totalWeight));
104
+ const remainder = shardableTotal - shardSizes.reduce((a, b) => a + b, 0);
105
+ for (let i = 0; i < remainder; i++) {
106
+ shardSizes[i % shardSizes.length]++;
107
+ }
108
+ let from = 0;
109
+ for (let i = 0; i < shard.current - 1; i++)
110
+ from += shardSizes[i];
111
+ const to = from + shardSizes[shard.current - 1];
104
112
  let current = 0;
105
113
  const result = /* @__PURE__ */ new Set();
106
114
  for (const group of testGroups) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playwright",
3
- "version": "1.58.0-alpha-2025-12-23",
3
+ "version": "1.58.0-alpha-1766484475000",
4
4
  "description": "A high-level API to automate web browsers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "license": "Apache-2.0",
66
66
  "dependencies": {
67
- "playwright-core": "1.58.0-alpha-2025-12-23"
67
+ "playwright-core": "1.58.0-alpha-1766484475000"
68
68
  },
69
69
  "optionalDependencies": {
70
70
  "fsevents": "2.3.2"