@empiricalrun/playwright-utils 0.59.0 → 0.60.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.
@@ -1 +1 @@
1
- {"version":3,"file":"test-case-sync.d.ts","sourceRoot":"","sources":["../../src/reporter/test-case-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EAErB,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK,EACV,UAAU,EAEV,KAAK,EAEN,MAAM,2BAA2B,CAAC;AAUnC,YAAY,EACV,uBAAuB,EACvB,6BAA6B,EAC7B,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,6CAA6C,CAAC;AAwRrD,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,KAAK,GACf,oBAAoB,CAyBtB"}
1
+ {"version":3,"file":"test-case-sync.d.ts","sourceRoot":"","sources":["../../src/reporter/test-case-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EAErB,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK,EACV,UAAU,EAEV,KAAK,EAEN,MAAM,2BAA2B,CAAC;AAUnC,YAAY,EACV,uBAAuB,EACvB,6BAA6B,EAC7B,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,6CAA6C,CAAC;AAgUrD,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,KAAK,GACf,oBAAoB,CAyBtB"}
@@ -15,6 +15,24 @@ function getSuiteParallelMode(suite) {
15
15
  ? mode
16
16
  : "none";
17
17
  }
18
+ /**
19
+ * The project's per-project `workers` cap, if it declares one.
20
+ *
21
+ * The public `FullProject` deliberately omits `workers`, so this reads the
22
+ * internal `FullProjectInternal` that Playwright attaches to every project
23
+ * suite (`buildProjectSuite` in `runner/loadUtils.ts` — the same object
24
+ * `suite.project()` resolves through, so it is present wherever projects
25
+ * are). Only explicit per-project caps surface here: the global `workers`
26
+ * setting resolves per machine (a `'50%'` default is a different number on
27
+ * the listing container than on a shard) and is not a per-project signal.
28
+ */
29
+ function getProjectWorkerCap(suite) {
30
+ const workers = suite
31
+ ._fullProject?.workers;
32
+ return typeof workers === "number" && Number.isFinite(workers) && workers >= 1
33
+ ? workers
34
+ : undefined;
35
+ }
18
36
  function toPosixPath(value) {
19
37
  return value.split(path_1.default.sep).join("/");
20
38
  }
@@ -138,6 +156,20 @@ function walkSuite(rootDir, suite, state, testCases, dependencyGroups) {
138
156
  const suites = isDescribe ? [...state.suites, suite.title] : state.suites;
139
157
  const nextState = { ...state, suites };
140
158
  const mode = getSuiteParallelMode(suite);
159
+ // A per-project `workers` cap constrains the whole project: the dispatcher
160
+ // enforces it per process (`_workerLimitPerProjectId`), so the guarantee
161
+ // only survives sharding if every test of the project lands on one shard.
162
+ // Emitted alongside any inner groups — it is the outermost scope, so it
163
+ // wins for scheduling and keeps the inner ones whole for free.
164
+ if (suite.type === "project") {
165
+ const workerCap = getProjectWorkerCap(suite);
166
+ if (workerCap !== undefined) {
167
+ const capGroup = buildDependencyGroup(rootDir, suite, nextState, "playwright_worker_cap", suite.allTests());
168
+ if (capGroup) {
169
+ dependencyGroups.push({ ...capGroup, worker_limit: workerCap });
170
+ }
171
+ }
172
+ }
141
173
  // A serial group is emitted even inside a default scope: the outer default
142
174
  // group wins for scheduling, but serial membership carries extra semantics
143
175
  // (failure cascade, re-expansion) its consumers still need.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.59.0",
3
+ "version": "0.60.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -41,7 +41,7 @@
41
41
  "openapi-typescript": "7.6.1",
42
42
  "playwright-core": "1.62.1",
43
43
  "serve-handler": "^6.1.6",
44
- "@empiricalrun/shared-types": "0.16.0"
44
+ "@empiricalrun/shared-types": "0.17.0"
45
45
  },
46
46
  "dependencies": {
47
47
  "@babel/code-frame": "^7.24.7",