-
Notifications
You must be signed in to change notification settings - Fork 436
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
79 lines (72 loc) · 2.31 KB
/
Copy pathplaywright.config.ts
File metadata and controls
79 lines (72 loc) · 2.31 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
68
69
70
71
72
73
74
75
76
77
78
79
import { defineConfig } from '@playwright/test';
const executablePath = process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH;
const externalBaseURL = process.env.PLAYWRIGHT_BASE_URL?.trim();
const configuredPort = Number(process.env.PLAYWRIGHT_PORT || '4173');
if (!Number.isInteger(configuredPort) || configuredPort < 1 || configuredPort > 65535) {
throw new Error(`Invalid PLAYWRIGHT_PORT: ${process.env.PLAYWRIGHT_PORT}`);
}
const baseURL = externalBaseURL || `http://127.0.0.1:${configuredPort}`;
const parsedBaseURL = new URL(baseURL);
const isLoopbackURL = ['127.0.0.1', 'localhost', '[::1]'].includes(parsedBaseURL.hostname);
const serverPort = parsedBaseURL.port
? Number(parsedBaseURL.port)
: parsedBaseURL.protocol === 'https:'
? 443
: 80;
if (!Number.isInteger(serverPort) || serverPort < 1 || serverPort > 65535) {
throw new Error(`Invalid Playwright base URL port: ${baseURL}`);
}
const launchOptions = executablePath ? {
executablePath,
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--disable-features=BlockInsecurePrivateNetworkRequests',
],
} : undefined;
export default defineConfig({
testDir: './tests',
outputDir: './test-results',
timeout: 60000,
use: {
baseURL,
screenshot: 'on',
trace: 'retain-on-failure',
},
projects: [
{
name: 'a11y',
testMatch: '**/a11y.spec.ts',
fullyParallel: true,
outputDir: './test-results/a11y',
use: {
browserName: 'chromium',
viewport: { width: 1280, height: 800 },
...(launchOptions ? { launchOptions } : {}),
},
},
{
name: 'functional',
testIgnore: '**/a11y.spec.ts',
fullyParallel: false,
workers: 1,
outputDir: './test-results/functional',
use: {
browserName: 'chromium',
viewport: { width: 1280, height: 800 },
...(launchOptions ? { launchOptions } : {}),
},
},
],
// A loopback PLAYWRIGHT_BASE_URL still needs a local renderer process.
// Only genuinely external URLs opt out of Playwright-managed startup.
...(!externalBaseURL || isLoopbackURL ? {
webServer: {
command: `npm run dev:renderer -- --host 127.0.0.1 --port ${serverPort} --no-hot`,
url: baseURL,
reuseExistingServer: !process.env.CI,
timeout: 120000,
},
} : {}),
});