@dionlarson/playwright-orchestrator-core 1.6.2 → 1.6.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.
|
@@ -4,7 +4,7 @@ export declare class RunBuilder {
|
|
|
4
4
|
private readonly testRun;
|
|
5
5
|
private config;
|
|
6
6
|
parseEntry(entry: TestCase | Suite): this;
|
|
7
|
-
parseConfig(config: FullConfig): this;
|
|
7
|
+
parseConfig(config: FullConfig, webServerOverride?: FullConfig['webServer'] | null): this;
|
|
8
8
|
private extractSetupConfig;
|
|
9
9
|
private extractWebServers;
|
|
10
10
|
private findSetupProjects;
|
|
@@ -5,7 +5,7 @@ export class RunBuilder {
|
|
|
5
5
|
this.parseSuitesHelper(entry);
|
|
6
6
|
return this;
|
|
7
7
|
}
|
|
8
|
-
parseConfig(config) {
|
|
8
|
+
parseConfig(config, webServerOverride) {
|
|
9
9
|
this.config = {
|
|
10
10
|
workers: config.workers,
|
|
11
11
|
configFile: config.configFile,
|
|
@@ -13,15 +13,17 @@ export class RunBuilder {
|
|
|
13
13
|
name: project.name,
|
|
14
14
|
outputDir: project.outputDir,
|
|
15
15
|
})),
|
|
16
|
-
setup: this.extractSetupConfig(config),
|
|
16
|
+
setup: this.extractSetupConfig(config, webServerOverride),
|
|
17
17
|
};
|
|
18
18
|
return this;
|
|
19
19
|
}
|
|
20
|
-
extractSetupConfig(config) {
|
|
20
|
+
extractSetupConfig(config, webServerOverride) {
|
|
21
|
+
// Use webServerOverride if provided (for --list mode where config.webServer is null)
|
|
22
|
+
const webServer = webServerOverride !== undefined ? webServerOverride : config.webServer;
|
|
21
23
|
return {
|
|
22
24
|
globalSetup: config.globalSetup ?? undefined,
|
|
23
25
|
globalTeardown: config.globalTeardown ?? undefined,
|
|
24
|
-
webServers: this.extractWebServers(
|
|
26
|
+
webServers: this.extractWebServers(webServer),
|
|
25
27
|
setupProjects: this.findSetupProjects(config.projects),
|
|
26
28
|
};
|
|
27
29
|
}
|
|
@@ -1,7 +1,49 @@
|
|
|
1
1
|
import { RunBuilder } from './run-builder.js';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
/**
|
|
5
|
+
* Synchronously load the playwright config to extract webServer configuration.
|
|
6
|
+
*
|
|
7
|
+
* When running `npx playwright test --list`, Playwright passes `config.webServer = null`
|
|
8
|
+
* to the reporter's onBegin method because webServers aren't started in list mode.
|
|
9
|
+
* Additionally, Playwright doesn't await async onBegin methods in --list mode.
|
|
10
|
+
*
|
|
11
|
+
* To capture webServer config for the orchestrator, we need to:
|
|
12
|
+
* 1. Use a synchronous approach (can't await)
|
|
13
|
+
* 2. Evaluate the config file directly to get the raw webServer definition
|
|
14
|
+
*/
|
|
15
|
+
function loadWebServerConfigSync(configFile) {
|
|
16
|
+
try {
|
|
17
|
+
const require = createRequire(import.meta.url);
|
|
18
|
+
const { execSync } = require('child_process');
|
|
19
|
+
// Use tsx to evaluate and extract just the webServer config
|
|
20
|
+
const resolvedPath = path.resolve(configFile);
|
|
21
|
+
const script = `const config = require('${resolvedPath.replace(/'/g, "\\'")}').default; console.log(JSON.stringify(config.webServer || null));`;
|
|
22
|
+
const result = execSync(`npx tsx -e "${script.replace(/"/g, '\\"')}"`, {
|
|
23
|
+
cwd: path.dirname(configFile),
|
|
24
|
+
encoding: 'utf-8',
|
|
25
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
26
|
+
});
|
|
27
|
+
return JSON.parse(result.trim());
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
console.error('[orchestrator] Failed to load webServer config:', e);
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
2
34
|
export default class RunInfoReporter {
|
|
3
35
|
onBegin(config, suite) {
|
|
4
|
-
|
|
36
|
+
// When using --list, Playwright doesn't populate config.webServer
|
|
37
|
+
// We need to load it directly from the config file synchronously
|
|
38
|
+
// because Playwright doesn't await async onBegin in --list mode
|
|
39
|
+
let webServer = config.webServer;
|
|
40
|
+
if (!webServer && config.configFile) {
|
|
41
|
+
webServer = loadWebServerConfigSync(config.configFile);
|
|
42
|
+
}
|
|
43
|
+
const testRunInfo = new RunBuilder()
|
|
44
|
+
.parseConfig(config, webServer)
|
|
45
|
+
.parseEntry(suite)
|
|
46
|
+
.build();
|
|
5
47
|
console.log(JSON.stringify(testRunInfo, null, 2));
|
|
6
48
|
}
|
|
7
49
|
}
|