-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcucumber.conf.js
49 lines (37 loc) · 1019 Bytes
/
cucumber.conf.js
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
const { setDefaultTimeout, AfterAll, BeforeAll } = require('@cucumber/cucumber');
const { createSession, closeSession, startWebDriver, stopWebDriver } = require('nightwatch-api');
const process = require("process");
class CucumberConf {
async _setup() {
const env = this.env;
console.log(this.env);
await startWebDriver({ env });
await createSession({ env });
}
async _shutdown() {
await closeSession();
await stopWebDriver();
}
_initEnv() {
const env = process.env.env.trim();
if (env === 'chrome') {
this.env = 'default';
} else if (env === 'firefox') {
this.env = 'firefox';
}
}
_setEvents() {
BeforeAll(async () => this._setup());
AfterAll(this._shutdown);
}
init() {
this._initEnv();
if (this.env) {
setDefaultTimeout(999999999);
this._setEvents();
} else {
console.log("Browser is not set. Set the 'env' environment variable to 'chrome' or 'firefox'.");
}
}
}
new CucumberConf().init();