-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject-configurations.ts
66 lines (59 loc) · 1.36 KB
/
project-configurations.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
61
62
63
64
65
66
import { devices, Project } from '@playwright/test';
import * as dotenv from 'dotenv';
import * as process from 'process';
import { Environment } from '@global/enums/environment';
dotenv.config();
const environments = {
[Environment.Local]: {
baseUrl: 'playwright.dev',
mailUrl: 'playwright.dev',
},
[Environment.Staging]: {
baseUrl: 'playwright.dev',
mailUrl: 'playwright.dev',
},
};
function getUrls(envName: Environment): Record<string, string> {
const environmentConfig = environments[envName];
const baseUrl = environmentConfig.baseUrl;
return {
baseURL: `https://${baseUrl}`,
mailUrl: `https://mail.${environmentConfig.mailUrl}`,
apiUrl: `https://api.${baseUrl}`,
host: baseUrl,
};
}
const { host, ...urls } = getUrls(process.env.PW_ENV as Environment);
global.HOST = host;
export const buildProjectsFor = (environment: string): Project[] => {
const viewport = { width: 1620, height: 980 };
return [
{
name: `${environment}-chrome`,
use: {
...urls,
...devices['Desktop Chrome'],
viewport,
isMobile: false,
},
},
{
name: `${environment}-safari`,
use: {
...urls,
...devices['Desktop Safari'],
viewport,
isMobile: false,
},
},
{
name: `${environment}-mobile`,
grepInvert: /@onlyDesktop/,
use: {
...urls,
...devices['iPhone 15 Pro Max'],
isMobile: true,
},
},
];
};