-
Notifications
You must be signed in to change notification settings - Fork 0
/
cucumber.conf.js
46 lines (41 loc) · 1.25 KB
/
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
const fs = require('fs');
const {
setDefaultTimeout, After, AfterAll, BeforeAll,
} = require('cucumber');
const {
createSession,
closeSession,
startWebDriver,
stopWebDriver,
getNewScreenshots,
} = require('nightwatch-api');
const reporter = require('cucumber-html-reporter');
// cucumber menset timeout 60 detik
setDefaultTimeout(60000);
// sebelum menjalankan testnya , cucumber terlebih dahulu menjalankan web driver dan kemudian membuat session
BeforeAll(async () => {
await startWebDriver();
await createSession();
});
// setelah testnya selesai, cucumber akan menutup session yang tadi dibuat dan memberhentikan/stop web driver, kemudian langsung load report
AfterAll(async () => {
await closeSession();
await stopWebDriver();
setTimeout(() => {
reporter.generate({
theme: 'bootstrap',
jsonFile: 'report/cucumber_report.json',
output: 'report/cucumber_report.html',
reportSuiteAsScenarios: true,
launchReport: true,
metadata: {
'App Version': '1.0.0',
'Test Environment': 'Google Production',
},
});
}, 1000);
});
// untuk create screenshot baru ketika test dijalankan
After(function () {
getNewScreenshots().forEach((file) => this.attach(fs.readFileSync(file), 'image/png'));
});