This repository has been archived by the owner on Jun 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nightwatch.conf.js
83 lines (78 loc) · 2.57 KB
/
nightwatch.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
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
const PKG = require('./package.json');
const BINPATH = './node_modules/nightwatch/bin/';
const SCREENSHOT_PATH = "./node_modules/nightwatch/screenshots/" + PKG.version + "/";
const config = {
"src_folders": [
"specs/e2e"
],
"output_folder": "./node_modules/nightwatch/reports",
"selenium": {
"start_process": true,
"server_path": BINPATH + "selenium.jar",
"log_path": "",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver" : BINPATH + "chromedriver"
}
},
"test_workers" : {"enabled" : true, "workers" : "auto"},
"test_settings": {
"default": {
"launch_url": "http://localhost",
"selenium_port": 4444,
"selenium_host": "127.0.0.1",
"silent": true,
"screenshots": {
"enabled": true,
"path": SCREENSHOT_PATH
},
"globals": {
"waitForConditionTimeout": 15000
},
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"args": [
"--window-size=640,640"
]
},
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
},
"custom_commands_path" : "node_modules/nightwatch-custom-commands-assertions/js/commands",
"custom_assertions_path" : "node_modules/nightwatch-custom-commands-assertions/js/assertions"
}
module.exports = config;
require('fs').stat(BINPATH + 'selenium.jar', function (err, stat) {
if (err || !stat || stat.size < 1) {
require('selenium-download').ensure(BINPATH, function(error) {
if (error) throw new Error(error);
console.log('✔ Selenium & Chromedriver downloaded to:', BINPATH);
});
}
});
function padLeft (count) {
return count < 10 ? '0' + count : count.toString();
}
var FILECOUNT = 0;
/**
* The default is to save screenshots to the root of your project even though
* there is a screenshots path in the config object above! ... so we need a
* function that returns the correct path for storing our screenshots.
* While we're at it, we are adding some meta-data to the filename, specifically
* the Platform/Browser where the test was run and the test (file) name.
*/
function imgpath (browser) {
var a = browser.options.desiredCapabilities;
var meta = [a.platform];
meta.push(a.browserName ? a.browserName : 'any');
meta.push(a.version ? a.version : 'any');
meta.push(a.name);
var metadata = meta.join('~').toLowerCase().replace(/ /g, '');
return SCREENSHOT_PATH + metadata + '_' + padLeft(FILECOUNT++) + '_';
}
module.exports.imgpath = imgpath;
module.exports.SCREENSHOT_PATH = SCREENSHOT_PATH;