/
index.ts
57 lines (49 loc) · 1.96 KB
/
index.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
// The purpose of this file is to be able to enable dynamic paramters to be passed via the actual cucumber arguments
// that we pass when calling the cucumber executable.
import dotenv from 'dotenv';
import { env, getJsonFromFile } from './env/parseEnv';
import {
GlobalConfig,
HostsConfig,
PagesConfig,
PageElementMappings,
FixtureMappings,
} from './env/global';
import * as fs from 'fs';
dotenv.config({path: env('COMMON_CONFIG_FILE')})
const hostsConfig: HostsConfig = getJsonFromFile(env('HOSTS_URLS_PATH'))
const pagesConfig: PagesConfig = getJsonFromFile(env('PAGE_URLS_PATH'))
const pageMappingFiles = fs.readdirSync(`${process.cwd()}${env('PAGE_ELEMENT_MAPPINGS_PATH')}`)
const pageElementMappings: PageElementMappings = pageMappingFiles.reduce(
(pageElementConfigAcc, file) => {
const key = file.replace('.json', '');
const elementMappings = getJsonFromFile(`${env('PAGE_ELEMENT_MAPPINGS_PATH')}${file}`);
return { ...pageElementConfigAcc, [key]: elementMappings}
},
{}
);
const fixtureMappingFiles = fs.readdirSync(`${process.cwd()}${env('FIXTURES_PATH')}`)
const fixtureMappings: FixtureMappings = fixtureMappingFiles.reduce(
(fixtureConfigAcc, file) => {
const key = file.replace('.json', '');
const fixturesMappings = getJsonFromFile(`${env('FIXTURES_PATH')}${file}`);
return { ...fixtureConfigAcc, [key]: fixturesMappings}
},
{}
);
const worldParameters: GlobalConfig = {
hostsConfig,
pagesConfig,
pageElementMappings,
fixtureMappings,
};
const common = `./src/features/**/*.feature \
--require-module ts-node/register \
--require ./src/step-definitions/**/**/*.ts \
--world-parameters ${JSON.stringify(worldParameters)} \
-f json:./reports/reports.json \
--format progress-bar`;
const dev = `${common} --tags '@dev'`;
const smoke = `${common} --tags '@smoke'`;
const regression = `${common} --tags '@regression'`;
export { dev, smoke, regression }