Repository navigation
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
67 lines (63 loc) · 2.38 KB
/
Copy pathplaywright.config.ts
File metadata and controls
67 lines (63 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { defineConfig } from "@playwright/test";
import { baseConfig, server } from "./playwright.shared.ts";
/** W-985: the seeded-bug runner's parallel e2e lanes each use their own demo port. */
const nodePort = Number(process.env["EMVB_E2E_NODE_PORT"] ?? 4411);
const cfPort = Number(process.env["EMVB_E2E_CF_PORT"] ?? 4412);
const allPlatforms = [
{
name: "node",
port: nodePort,
command:
nodePort === 4411
? "bun run demo:node"
: `bun run --cwd demos/node astro dev --host 127.0.0.1 --port ${nodePort}`,
},
{
name: "cloudflare",
port: cfPort,
command:
cfPort === 4412
? "bun run demo:cf"
: `bun run --cwd demos/cloudflare astro dev --host 127.0.0.1 --port ${cfPort}`,
},
] as const;
/**
* `EMVB_E2E_PLATFORM=node` (or `cloudflare`) runs one platform and starts only its demo server,
* so `bun run e2e:full` can run both side by side, each with its own server and data.
*/
const only = process.env["EMVB_E2E_PLATFORM"];
/**
* W-960: `--project=node` (as the seeded-bug runner and single-spec runs pass it) starts only the
* node demo server, not both; a run without --project starts both.
*/
function requestedPlatforms(argv: readonly string[]): Set<string> | undefined {
const names: string[] = [];
argv.forEach((arg, i) => {
if (arg.startsWith("--project=")) names.push(arg.slice("--project=".length));
else if (arg === "--project" && argv[i + 1]) names.push(argv[i + 1] as string);
});
if (names.length === 0) return undefined;
return new Set(names.map((name) => name.replace(/-setup$/, "")));
}
const requested = requestedPlatforms(process.argv);
const platforms = allPlatforms.filter((p) => !only || p.name === only);
// Only the servers: workers re-read this file without the CLI flags, so the projects stay the same.
const servers = platforms.filter((p) => !requested || requested.has(p.name));
export default defineConfig({
...baseConfig,
testDir: "./e2e",
testMatch: /.*\.e2e\.ts$/,
projects: platforms.flatMap(({ name, port }) => [
{
name: `${name}-setup`,
testMatch: /auth\.setup\.ts$/,
use: { baseURL: `http://127.0.0.1:${port}` },
},
{
name,
dependencies: [`${name}-setup`],
use: { baseURL: `http://127.0.0.1:${port}`, storageState: `e2e/.auth/${name}.json` },
},
]),
webServer: servers.map(({ port, command }) => server(command, port, 180_000)),
});