@lenne.tech/cli 1.41.2 → 1.41.3
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/build/lib/dev-test-session.js +58 -14
- package/package.json +1 -1
|
@@ -13,9 +13,11 @@ exports.TEST_INITIAL_ADMIN_ENV = void 0;
|
|
|
13
13
|
exports.ensurePlaywrightBrowsers = ensurePlaywrightBrowsers;
|
|
14
14
|
exports.autoShardCount = autoShardCount;
|
|
15
15
|
exports.bringUpTestSession = bringUpTestSession;
|
|
16
|
+
exports.buildShardPlaywrightInvocation = buildShardPlaywrightInvocation;
|
|
16
17
|
exports.hasTestSession = hasTestSession;
|
|
17
18
|
exports.resolveTestSession = resolveTestSession;
|
|
18
19
|
exports.runShardedTestSession = runShardedTestSession;
|
|
20
|
+
exports.shardReportDir = shardReportDir;
|
|
19
21
|
exports.tearDownAllTestSessions = tearDownAllTestSessions;
|
|
20
22
|
exports.tearDownTestSession = tearDownTestSession;
|
|
21
23
|
/**
|
|
@@ -341,6 +343,45 @@ function bringUpTestSession(layout_1, baseIdentity_1, log_1) {
|
|
|
341
343
|
return { apiLogPath, apiUrl, appEnv: devEnv.app.env, appUrl, dbName, pids, testIdentity };
|
|
342
344
|
});
|
|
343
345
|
}
|
|
346
|
+
/**
|
|
347
|
+
* Build the Playwright CLI argv + per-shard env overrides for ONE shard of a
|
|
348
|
+
* `lt dev test --shard` run.
|
|
349
|
+
*
|
|
350
|
+
* DEV-2676 — reporter handling: this path must NOT pass `--reporter`. A CLI
|
|
351
|
+
* `--reporter` REPLACES the project's whole `reporter` list from
|
|
352
|
+
* playwright.config.ts (Playwright resolves CLI-over-config, it never appends —
|
|
353
|
+
* `Runner._parseConfig` in playwright's `lib/runner/index.js` does
|
|
354
|
+
* `result.reporter = [...configOverrides.reporter]`), silently dropping any
|
|
355
|
+
* release gate a project wires in AS a reporter. SVL's DEV-2098 gate (`./tests/no-skips.reporter.ts`)
|
|
356
|
+
* turns a run RED when a spec was skipped; the old `--reporter=line` here
|
|
357
|
+
* clobbered it, so a skipped test passed with exit 0 under `--shard` — the exact
|
|
358
|
+
* hole this closes. Omitting `--reporter` lets the configured reporters run (the
|
|
359
|
+
* gate included); Playwright auto-prepends a compact `line` (local) / `dot` (CI)
|
|
360
|
+
* reporter when none of them claim stdio, so the captured per-shard log stays
|
|
361
|
+
* readable without us overriding anything.
|
|
362
|
+
*
|
|
363
|
+
* The HTML reporter is the only common config reporter that is shard-hostile:
|
|
364
|
+
* every shard shares one project dir and would write the same
|
|
365
|
+
* `playwright-report/`, racing each other's report files. We hand each shard its
|
|
366
|
+
* own HTML output dir and force `open: never` (defensive — the non-TTY,
|
|
367
|
+
* file-captured child never auto-opens a browser anyway). Both env vars are
|
|
368
|
+
* inert for a project without an HTML reporter, so the fix stays generic.
|
|
369
|
+
*
|
|
370
|
+
* Playwright is invoked via the manager's `exec` (NOT `<pm> run test:e2e -- …`):
|
|
371
|
+
* forwarding option flags through `<pm> run`'s `--` is unreliable — pnpm passed
|
|
372
|
+
* the separator on to Playwright, which then read `--shard` as a file FILTER, so
|
|
373
|
+
* every shard ran the whole suite. `exec` hands args straight to the binary
|
|
374
|
+
* (mirrors CI); the helper inserts `--` for npm so those flags survive.
|
|
375
|
+
*/
|
|
376
|
+
function buildShardPlaywrightInvocation(pm, shardIndex, total, forwarded, htmlReportDir) {
|
|
377
|
+
return {
|
|
378
|
+
args: pm.exec('playwright', ['test', `--shard=${shardIndex}/${total}`, ...forwarded]),
|
|
379
|
+
env: {
|
|
380
|
+
PLAYWRIGHT_HTML_OPEN: 'never',
|
|
381
|
+
PLAYWRIGHT_HTML_OUTPUT_DIR: htmlReportDir,
|
|
382
|
+
},
|
|
383
|
+
};
|
|
384
|
+
}
|
|
344
385
|
/** True when a test session file exists (used by status/down). */
|
|
345
386
|
function hasTestSession(root) {
|
|
346
387
|
return (0, dev_state_1.loadSession)(root, dev_state_1.TEST_SESSION_FILE) !== null;
|
|
@@ -396,21 +437,14 @@ function runShardedTestSession(layout, baseIdentity, log, opts) {
|
|
|
396
437
|
// suite runs under concurrent sharded load, so it can relax navigation /
|
|
397
438
|
// test timeouts (N built SSR servers + N Chromium saturate the CPU and slow
|
|
398
439
|
// every navigation) without loosening them for serial runs.
|
|
399
|
-
|
|
440
|
+
// Reporter + shard args come from the shared helper, which deliberately
|
|
441
|
+
// does NOT inject `--reporter` so the project's own release gate (e.g.
|
|
442
|
+
// SVL's DEV-2098 no-skips reporter) still runs under `--shard` (DEV-2676),
|
|
443
|
+
// and isolates the HTML report per shard.
|
|
444
|
+
const reportDir = shardReportDir(layout.root, index);
|
|
445
|
+
const { args, env: reporterEnv } = buildShardPlaywrightInvocation(opts.pm, index, total, opts.forwarded, reportDir);
|
|
446
|
+
const env = Object.assign(Object.assign(Object.assign(Object.assign({}, ctx.appEnv), { LT_DEV_TEST_SHARDS: String(total), MONGO_URI: `mongodb://127.0.0.1/${ctx.dbName}` }), (ctx.apiLogPath ? { NEST_SERVER_LOG: ctx.apiLogPath } : {})), reporterEnv);
|
|
400
447
|
const logFile = (0, path_1.join)(layout.root, '.lt-dev', `shard.${index}.test.log`);
|
|
401
|
-
// Invoke Playwright DIRECTLY via the manager's `exec` (NOT `<pm> run
|
|
402
|
-
// test:e2e -- …`): forwarding option flags through `<pm> run`'s `--`
|
|
403
|
-
// is unreliable — pnpm passed the separator on to Playwright, which
|
|
404
|
-
// then read `--shard` / `--reporter` as file FILTERS (not options) →
|
|
405
|
-
// every shard ran the whole suite. `<pm> exec` hands args straight
|
|
406
|
-
// to the binary (mirrors CI); the helper inserts `--` for npm so
|
|
407
|
-
// those flags don't get re-parsed as npm's own.
|
|
408
|
-
const args = opts.pm.exec('playwright', [
|
|
409
|
-
'test',
|
|
410
|
-
`--shard=${index}/${total}`,
|
|
411
|
-
'--reporter=line',
|
|
412
|
-
...opts.forwarded,
|
|
413
|
-
]);
|
|
414
448
|
const code = yield (0, dev_process_1.runChildToFile)(opts.pm.bin, args, { cwd: appDir, env, logFile });
|
|
415
449
|
return { code, index, logFile };
|
|
416
450
|
})));
|
|
@@ -426,6 +460,16 @@ function runShardedTestSession(layout, baseIdentity, log, opts) {
|
|
|
426
460
|
return failed === 0 ? 0 : 1;
|
|
427
461
|
});
|
|
428
462
|
}
|
|
463
|
+
/**
|
|
464
|
+
* The per-shard HTML report directory. Distinct per shard (the `<index>` in the
|
|
465
|
+
* path) so N shards never race on a shared `playwright-report/` — this is the
|
|
466
|
+
* actual isolation `buildShardPlaywrightInvocation`'s `PLAYWRIGHT_HTML_OUTPUT_DIR`
|
|
467
|
+
* relies on. Extracted as a pure helper so the shard-distinctness guarantee is
|
|
468
|
+
* unit-testable without booting the (deliberately untested) real orchestrator.
|
|
469
|
+
*/
|
|
470
|
+
function shardReportDir(root, shardIndex) {
|
|
471
|
+
return (0, path_1.join)(root, '.lt-dev', `shard.${shardIndex}.playwright-report`);
|
|
472
|
+
}
|
|
429
473
|
/**
|
|
430
474
|
* Tear down the unsharded test stack AND every sharded stack discovered on disk
|
|
431
475
|
* (`state.test.<i>.json` in `.lt-dev/`). Used by `lt dev test down` so a
|