@dionlarson/playwright-orchestrator-core 1.3.9 → 1.4.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.
package/dist/adapter.d.ts CHANGED
@@ -11,6 +11,7 @@ export declare abstract class Adapter {
11
11
  abstract finishShard(runId: string): Promise<void>;
12
12
  abstract getReportData(runId: string): Promise<TestRunReport>;
13
13
  abstract dispose(): Promise<void>;
14
+ abstract cleanupStaleTests(runId: string, staleMinutes: number): Promise<number>;
14
15
  protected transformTestRunToItems(run: TestRun): ReporterTestItem[];
15
16
  protected sortTests(tests: ReporterTestItem[], testInfoMap: Map<string, TestSortItem>, { historyWindow, reverse }: SortTestsOptions): ReporterTestItem[];
16
17
  private extractCompareValue;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import { loadPlugins } from '../helpers/plugin.js';
2
+ import { withErrorHandling } from './error-handler.js';
3
+ import { program } from './program.js';
4
+ export default async () => {
5
+ const command = program.command('cleanup').description('Reset stale tests for a run');
6
+ for await (const { factory, subCommand } of loadPlugins(command)) {
7
+ subCommand
8
+ .requiredOption('--run-id <string>', 'Run id to cleanup')
9
+ .option('--stale-minutes <number>', 'Consider tests stale after N minutes', '10')
10
+ .action(withErrorHandling(async (options) => {
11
+ const adapter = await factory(options);
12
+ const count = await adapter.cleanupStaleTests(options.runId, parseInt(options.staleMinutes));
13
+ console.log(`Reset ${count} stale tests`);
14
+ await adapter.dispose();
15
+ }));
16
+ }
17
+ };
@@ -3,6 +3,7 @@ import init from './init.js';
3
3
  import run from './run.js';
4
4
  import create from './create.js';
5
5
  import createReport from './create-report.js';
6
+ import cleanup from './cleanup.js';
6
7
  import { readFile } from 'node:fs/promises';
7
8
  import { fileURLToPath } from 'node:url';
8
9
  import { dirname, join } from 'node:path';
@@ -17,4 +18,5 @@ await init();
17
18
  await run();
18
19
  await create();
19
20
  await createReport();
21
+ await cleanup();
20
22
  program.parse();
@@ -59,10 +59,21 @@ export class TestRunner {
59
59
  runningTests.delete(testPromise);
60
60
  });
61
61
  runningTests.add(testPromise);
62
- next = await this.adapter.getNextTest(this.runId, config);
62
+ // Only prefetch if we still have capacity after starting this test
63
+ // This prevents claiming more tests than we can run with workers=1
64
+ if (runningTests.size < config.workers) {
65
+ next = await this.adapter.getNextTest(this.runId, config);
66
+ }
67
+ else {
68
+ next = undefined;
69
+ }
63
70
  }
64
71
  else {
65
72
  await Promise.race(runningTests);
73
+ // Fetch next test after a slot opens up
74
+ if (!next) {
75
+ next = await this.adapter.getNextTest(this.runId, config);
76
+ }
66
77
  }
67
78
  }
68
79
  console.log(`[orchestrator] Finished ${testCount} tests`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dionlarson/playwright-orchestrator-core",
3
- "version": "1.3.9",
3
+ "version": "1.4.0",
4
4
  "description": "Core lib and cli for Playwright test orchestration",
5
5
  "keywords": [
6
6
  "playwright",