-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaywright.config.ts
56 lines (48 loc) · 1.45 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
import { defineConfig, devices, type PlaywrightTestConfig, PlaywrightTestProject } from "@playwright/test";
const { CI, PORT, LOGS_ENABLED, PLAYWRIGHT_WORKERS } = process.env;
const port = PORT;
const timeout = 30000;
const baseURL = `http://localhost:${port}`;
const nextDev = `next dev --turbo -p ${port}`;
const testDir = "test/browser";
const command = LOGS_ENABLED ? nextDev : `${nextDev} &>/dev/null`;
const browserTestSetupProjectName = "browser-test-setup";
const browserTestSetup: PlaywrightTestProject = {
name: browserTestSetupProjectName,
testMatch: /browser-test-setup\.ts/,
};
const browserTests: PlaywrightTestProject = {
name: "browser tests",
dependencies: [browserTestSetupProjectName],
use: {
...devices["Desktop Chrome"],
viewport: { height: 844, width: 390 },
},
testDir,
};
const localWebServer: PlaywrightTestConfig = {
webServer: {
timeout,
command,
reuseExistingServer: !CI,
stdout: LOGS_ENABLED ? "pipe" : "ignore",
},
};
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir,
timeout,
expect: { timeout: 15000 },
fullyParallel: true,
forbidOnly: !!CI,
retries: CI ? 2 : 1,
workers: PLAYWRIGHT_WORKERS ?? 4,
reporter: "html",
use: { baseURL, trace: "on-first-retry" },
projects: [browserTestSetup, browserTests],
...localWebServer,
});
// eslint-disable-next-line no-console
console.log(`Running playwright tests against: ${baseURL}`);