-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ts
More file actions
42 lines (31 loc) · 1.16 KB
/
config.ts
File metadata and controls
42 lines (31 loc) · 1.16 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
import { expect } from '@playwright/test';
import config from './config-data.json';
const env: string = process.env.ENV_NAME || 'test';
const configuration = getConfig();
export function getBaseUrl(): string {
validate(configuration.baseUrl, 'baseUrl');
return configuration.baseUrl;
}
export function getBaseApiUrl(): string {
validate(configuration.baseApiUrl, 'baseApiUrl');
return configuration.baseApiUrl;
}
export function getUsername(): string {
validate(configuration.username, 'username');
return configuration.username;
}
export function getPassword(): string {
validate(configuration.password, 'password');
return configuration.password;
}
export function getLanguage(): string{
return configuration.language;
}
function getConfig(): any {
return config[env];
}
function validate(property: any, propertyName:string){
expect(property, `The ${propertyName} must not be undefined. Check the config.json file`).not.toBeUndefined();
expect(property, `The ${propertyName} must not be null. Check the config.json file`).not.toBeNull();
expect(property, `The ${ propertyName } must not be empty. Check the config.json file`).not.toEqual('');
}