-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaywright.config.ts
60 lines (51 loc) · 1.28 KB
/
playwright.config.ts
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
import { readdir } from "node:fs/promises";
import { defineConfig, devices } from "@playwright/test";
let port = 3000;
const fixtures = await readdir("./test/fixtures");
const envs = ["bun", "node"];
interface App {
url: string;
command: string;
testFile: string;
name: string;
}
const APPS = envs.reduce((apps, env) => {
return apps.concat(
...fixtures.map((fixture) => ({
url: `http://localhost:${port}`,
command: `bun ./scripts/server.ts test/fixtures/${fixture}/dist/${env} ${port++}`,
testFile: `**/${fixture}.spec.ts`,
name: env,
})),
);
}, [] as App[]);
/**
* See https://playwright.dev/docs/test-configuration.
*/
const config = defineConfig({
name: "E2E Tests",
outputDir: "test-results",
reporter: "html",
testDir: "./test/e2e",
/* Configure projects for major browsers */
projects: APPS.map((app) => {
return {
name: app.name,
use: {
...devices["Desktop Chrome"],
baseURL: app.url,
},
testMatch: app.testFile,
};
}),
/* Run local dev server before starting the tests */
webServer: APPS.map((app) => {
return {
command: app.command,
url: app.url,
timeout: 60 * 1000, // 60 seconds
reuseExistingServer: false,
};
}),
});
export default config;