-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
85 lines (72 loc) · 2.01 KB
/
index.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const ip = require('ip');
const allure = require('./lib/allure.js');
const video = require('./lib/video.js');
const config = require('./lib/config.js');
const helpers = require('./lib/helpers.js');
const wdio = {
/**
* Get ready for tests
* - find local ip
* - Init video interface
*/
before(browser) {
browser.globals = browser.globals || {};
browser.globals.ip = ip.address(); // Used by tests since we run webserver on local machine, feel free to override
helpers.runIfVideoEnabled(browser, () => {
video.init(browser);
});
},
/**
* Start recording before each test
* Pause a short while to get nice video
*/
beforeTest(browser, test, { size, framerate, codec, pixelFormat }) {
// Generate filename for screenshots and video
browser.globals.currentRecordingName = helpers.generateFilename(browser, test);
helpers.runIfVideoEnabled(browser, () => {
video.startRecording({
browser,
size,
framerate,
codec,
pixelFormat,
});
});
},
/**
* Stop recording after each test
*/
afterTest(browser, test, outputDir) {
helpers.runIfVideoEnabled(browser, () => {
video.stopRecording({
browser: browser,
save: !test.passed || config.saveAllVideos,
});
});
if (config.usingAllure) {
allure.addAttachments(browser, test, outputDir);
}
},
/**
* Finalize report if using allure
* Close all video recorders
*/
onComplete(wdioConfig, shortenSeleniumUrls) {
if (config.usingAllure) {
allure.finalizeReport(wdioConfig, shortenSeleniumUrls);
}
video.closeAll();
},
};
module.exports = {
getWdioHooks({ usingAllure=true, saveAllVideos=false, videoMinTime=50, screenshots=false, removeSteps=false }) {
config.usingAllure = usingAllure;
config.saveAllVideos = saveAllVideos;
config.videoMinTime = videoMinTime;
config.screenshots = screenshots;
config.removeSteps = removeSteps;
return wdio;
},
video,
config,
}