webship-js 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +3 -0
- package/.eslintrc.json +34 -0
- package/bin/webship-js-di.js +159 -0
- package/bin/webship-js-dl.js +142 -0
- package/nightwatch.conf.js +106 -106
- package/package.json +15 -4
- package/tests/step-definitions/webship.js +8 -12
- package/bin/webship-js-di +0 -87
- package/bin/webship-js-dl +0 -70
package/.eslintignore
ADDED
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": [
|
|
3
|
+
"airbnb-base"
|
|
4
|
+
],
|
|
5
|
+
"root": true,
|
|
6
|
+
"env": {
|
|
7
|
+
"browser": true,
|
|
8
|
+
"node": true
|
|
9
|
+
},
|
|
10
|
+
"globals": {
|
|
11
|
+
"loadjs": true
|
|
12
|
+
},
|
|
13
|
+
"rules": {
|
|
14
|
+
"consistent-return": ["off"],
|
|
15
|
+
"no-underscore-dangle": ["off"],
|
|
16
|
+
"max-nested-callbacks": ["warn", 5],
|
|
17
|
+
"import/no-mutable-exports": ["warn"],
|
|
18
|
+
"no-console": ["off"],
|
|
19
|
+
"no-plusplus": ["warn", {
|
|
20
|
+
"allowForLoopAfterthoughts": true
|
|
21
|
+
}],
|
|
22
|
+
"no-param-reassign": ["off"],
|
|
23
|
+
"no-prototype-builtins": ["off"],
|
|
24
|
+
"valid-jsdoc": ["warn", {
|
|
25
|
+
"prefer": {
|
|
26
|
+
"returns": "return",
|
|
27
|
+
"property": "prop"
|
|
28
|
+
},
|
|
29
|
+
"requireReturn": false
|
|
30
|
+
}],
|
|
31
|
+
"no-unused-vars": ["warn"],
|
|
32
|
+
"operator-linebreak": ["error", "after", { "overrides": { "?": "ignore", ":": "ignore" } }]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const conf = require('../nightwatch.conf.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Folders Path Array variable
|
|
8
|
+
*
|
|
9
|
+
* Set and Get folders path exist in (--config) tag and
|
|
10
|
+
* (--src_folder) tag added in nodejs command line.
|
|
11
|
+
*/
|
|
12
|
+
let foldersPath = [];
|
|
13
|
+
function setFoldersPath(value) {
|
|
14
|
+
value.forEach((element) => {
|
|
15
|
+
foldersPath.push(element);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Output Format name variable
|
|
21
|
+
*
|
|
22
|
+
* Set and Get Output Format exist in (--format) tag added
|
|
23
|
+
* in nodejs command line.
|
|
24
|
+
*/
|
|
25
|
+
let outputFormat = 'stdout-spaces';
|
|
26
|
+
function setOutputFormat(value) { outputFormat = value; }
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Start with Function.
|
|
30
|
+
*
|
|
31
|
+
* Return list of array items that start with
|
|
32
|
+
* (Given, Then, When, /** ,* , *\).
|
|
33
|
+
*
|
|
34
|
+
* @param {array} stepsList The full step-definitions file lines list.
|
|
35
|
+
* @return {array} The array has only lines startsWith words chosen.
|
|
36
|
+
*/
|
|
37
|
+
function startWith(stepsList) {
|
|
38
|
+
return (stepsList.startsWith('Given') ||
|
|
39
|
+
stepsList.startsWith('Then') ||
|
|
40
|
+
stepsList.startsWith('When') ||
|
|
41
|
+
stepsList.startsWith('/**') ||
|
|
42
|
+
stepsList.startsWith('* ') ||
|
|
43
|
+
stepsList.startsWith('*/'));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Filter Step Definitions
|
|
48
|
+
*
|
|
49
|
+
* @param {array} stepsList The step definitions array is sent to filter
|
|
50
|
+
* by startsWith words chosen.
|
|
51
|
+
* @return {array} Step definitions filtered array.
|
|
52
|
+
*/
|
|
53
|
+
function callStartsWith(stepsList) {
|
|
54
|
+
return stepsList.filter(startWith);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Clean Steps List
|
|
59
|
+
*
|
|
60
|
+
* Return list of array items cleand from unreadable chars.
|
|
61
|
+
*
|
|
62
|
+
* @param {array} stepsList The step definitions array before
|
|
63
|
+
* clean unreadable signs.
|
|
64
|
+
* @return {array} The step definitions cleaned array.
|
|
65
|
+
*/
|
|
66
|
+
function stepsCleanList(stepsList) {
|
|
67
|
+
let stepComment = '';
|
|
68
|
+
const newStepsList = [];
|
|
69
|
+
|
|
70
|
+
stepsList.forEach((element) => {
|
|
71
|
+
if (element.startsWith('* ')) {
|
|
72
|
+
element = element.replace('* ', '');
|
|
73
|
+
|
|
74
|
+
if (stepComment === '') stepComment = element;
|
|
75
|
+
else stepComment = `${stepComment}\r\n${element}`;
|
|
76
|
+
} else if (!element.startsWith('/**') && !element.startsWith('*/')) {
|
|
77
|
+
const filter1 = element.split('$/');
|
|
78
|
+
const filter2 = filter1[0].replace('(/^', ' ');
|
|
79
|
+
|
|
80
|
+
if (stepComment !== '') {
|
|
81
|
+
if (outputFormat.startsWith('html')) newStepsList.push(`${filter2}\r\n<div>${stepComment}</div>`);
|
|
82
|
+
else newStepsList.push(`${filter2}\r\n${stepComment}`);
|
|
83
|
+
} else newStepsList.push(filter2);
|
|
84
|
+
|
|
85
|
+
stepComment = '';
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return newStepsList;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function srcFolderPaths(path) {
|
|
92
|
+
const splitConfig = path.split('=');
|
|
93
|
+
const pathsLine = splitConfig[1];
|
|
94
|
+
const paths = pathsLine.split(' ');
|
|
95
|
+
|
|
96
|
+
setFoldersPath(paths);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* "foldersPath" array
|
|
101
|
+
*
|
|
102
|
+
* Fill "foldersPath" array process, that has paths of
|
|
103
|
+
* all folders contain step definitions js files.
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
for (let i = 2; i < process.argv.length; i++) {
|
|
107
|
+
if (process.argv[i].startsWith('--config')) {
|
|
108
|
+
const splitConfig = process.argv[i].split('=');
|
|
109
|
+
const path = splitConfig[1];
|
|
110
|
+
const configPath = require(path);
|
|
111
|
+
|
|
112
|
+
let configPathsArray = [];
|
|
113
|
+
configPathsArray = configPath.src_folders;
|
|
114
|
+
|
|
115
|
+
setFoldersPath(configPathsArray);
|
|
116
|
+
} else if (process.argv[i].startsWith('--src_folders')) {
|
|
117
|
+
srcFolderPaths(process.argv[i]);
|
|
118
|
+
} else if (process.argv[i].startsWith('--format')) {
|
|
119
|
+
setOutputFormat(process.argv[i].split('=')[1]);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (foldersPath.length === 0) foldersPath = conf.src_folders;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Step definitions list
|
|
127
|
+
*
|
|
128
|
+
* Get clear step definitions list from js
|
|
129
|
+
* step definitions files.
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
foldersPath.forEach((folderPath) => {
|
|
133
|
+
fs.readdir(folderPath, (err, files) => {
|
|
134
|
+
if (err) {
|
|
135
|
+
return console.log(`Unable to scan directory: ${err}`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
files.forEach((file) => {
|
|
139
|
+
fs.readFile(`./${folderPath}/${file}`, 'utf8', (err, data) => {
|
|
140
|
+
if (err) {
|
|
141
|
+
throw new Error(err);
|
|
142
|
+
}
|
|
143
|
+
const contentLines = data.split('\n');
|
|
144
|
+
const contentTrimmed = contentLines.map((element) => element.trim());
|
|
145
|
+
|
|
146
|
+
const stepsStartWith = callStartsWith(contentTrimmed);
|
|
147
|
+
const stepsList = stepsCleanList(stepsStartWith);
|
|
148
|
+
|
|
149
|
+
stepsList.forEach((element) => {
|
|
150
|
+
if (outputFormat.startsWith('stdout')) {
|
|
151
|
+
console.log(element);
|
|
152
|
+
} else if (outputFormat.startsWith('html')) {
|
|
153
|
+
console.log(`<div>${element}</div>`);
|
|
154
|
+
} else { console.log(element); }
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
});
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const conf = require('../nightwatch.conf.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Folders Path Array variable
|
|
8
|
+
*
|
|
9
|
+
* Set and Get folders path exist in (--config) tag and
|
|
10
|
+
* (--src_folder) tag added in nodejs command line.
|
|
11
|
+
*/
|
|
12
|
+
let foldersPath = [];
|
|
13
|
+
function setFoldersPath(value) {
|
|
14
|
+
value.forEach((element) => {
|
|
15
|
+
foldersPath.push(element);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Output Format name variable
|
|
21
|
+
*
|
|
22
|
+
* Set and Get Output Format exist in (--format) tag added
|
|
23
|
+
* in nodejs command line.
|
|
24
|
+
*/
|
|
25
|
+
let outputFormat = 'stdout-spaces';
|
|
26
|
+
function setOutputFormat(value) { outputFormat = value; }
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Start with Function.
|
|
30
|
+
*
|
|
31
|
+
* Return list of array items that start with (Given, Then, When).
|
|
32
|
+
*
|
|
33
|
+
* @param {array} stepsList The full step-definitions file lines list.
|
|
34
|
+
* @return {array} The array has only lines startsWith words chosen.
|
|
35
|
+
*/
|
|
36
|
+
function startWith(stepsList) {
|
|
37
|
+
return (stepsList.startsWith('Given') ||
|
|
38
|
+
stepsList.startsWith('Then') ||
|
|
39
|
+
stepsList.startsWith('When'));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Filter Step Definitions
|
|
44
|
+
*
|
|
45
|
+
* @param {array} stepsList The step definitions array is sent to filter
|
|
46
|
+
* by startsWith words chosen.
|
|
47
|
+
* @return {array} Step definitions filtered array.
|
|
48
|
+
*/
|
|
49
|
+
function callStartsWith(stepsList) {
|
|
50
|
+
return stepsList.filter(startWith);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Clean Steps List
|
|
55
|
+
*
|
|
56
|
+
* Return list of array items cleand from unreadable chars.
|
|
57
|
+
*
|
|
58
|
+
* @param {array} stepsList The step definitions array before clean
|
|
59
|
+
* unreadable signs.
|
|
60
|
+
* @return {array} The step definitions cleaned array.
|
|
61
|
+
*/
|
|
62
|
+
function stepsCleanList(stepsList) {
|
|
63
|
+
const newStepsList = [];
|
|
64
|
+
|
|
65
|
+
stepsList.forEach((element) => {
|
|
66
|
+
const filter1 = element.split('$/');
|
|
67
|
+
const filter2 = filter1[0].replace('(/^', ' ');
|
|
68
|
+
|
|
69
|
+
newStepsList.push(filter2);
|
|
70
|
+
});
|
|
71
|
+
return newStepsList;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function srcFolderPaths(path) {
|
|
75
|
+
const splitConfig = path.split('=');
|
|
76
|
+
const pathsLine = splitConfig[1];
|
|
77
|
+
const paths = pathsLine.split(' ');
|
|
78
|
+
|
|
79
|
+
setFoldersPath(paths);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* "foldersPath" array
|
|
84
|
+
*
|
|
85
|
+
* Fill "foldersPath" array process, that has paths of
|
|
86
|
+
* all folders contain step definitions js files.
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
for (let i = 2; i < process.argv.length; i++) {
|
|
90
|
+
if (process.argv[i].startsWith('--config')) {
|
|
91
|
+
const splitConfig = process.argv[i].split('=');
|
|
92
|
+
const path = splitConfig[1];
|
|
93
|
+
const configPath = require(path);
|
|
94
|
+
|
|
95
|
+
let configPathsArray = [];
|
|
96
|
+
configPathsArray = configPath.src_folders;
|
|
97
|
+
|
|
98
|
+
setFoldersPath(configPathsArray);
|
|
99
|
+
} else if (process.argv[i].startsWith('--src_folders')) {
|
|
100
|
+
srcFolderPaths(process.argv[i]);
|
|
101
|
+
} else if (process.argv[i].startsWith('--format')) {
|
|
102
|
+
setOutputFormat(process.argv[i].split('=')[1]);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (foldersPath.length === 0) foldersPath = conf.src_folders;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Step definitions list
|
|
110
|
+
*
|
|
111
|
+
* Get clear step definitions list from js
|
|
112
|
+
* step definitions files.
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
foldersPath.forEach((folderPath) => {
|
|
116
|
+
fs.readdir(folderPath, (err, files) => {
|
|
117
|
+
if (err) {
|
|
118
|
+
return console.log(`Unable to scan directory: ${err}`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
files.forEach((file) => {
|
|
122
|
+
fs.readFile(`./${folderPath}/${file}`, 'utf8', (err, data) => {
|
|
123
|
+
if (err) {
|
|
124
|
+
throw new Error(err);
|
|
125
|
+
}
|
|
126
|
+
const contentLines = data.split('\n');
|
|
127
|
+
const contentTrimmed = contentLines.map((element) => element.trim());
|
|
128
|
+
|
|
129
|
+
const stepsStartWith = callStartsWith(contentTrimmed);
|
|
130
|
+
const stepsList = stepsCleanList(stepsStartWith);
|
|
131
|
+
|
|
132
|
+
stepsList.forEach((element) => {
|
|
133
|
+
if (outputFormat.startsWith('stdout')) {
|
|
134
|
+
console.log(element);
|
|
135
|
+
} else if (outputFormat.startsWith('html')) {
|
|
136
|
+
console.log(`<div>${element}</div>`);
|
|
137
|
+
} else { console.log(element); }
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
});
|
package/nightwatch.conf.js
CHANGED
|
@@ -33,65 +33,65 @@ module.exports = {
|
|
|
33
33
|
options: {
|
|
34
34
|
feature_path: 'tests/features/*.feature',
|
|
35
35
|
additional_config: '',
|
|
36
|
-
parallel: 2
|
|
37
|
-
}
|
|
38
|
-
|
|
36
|
+
parallel: 2,
|
|
37
|
+
},
|
|
38
|
+
|
|
39
39
|
},
|
|
40
40
|
|
|
41
41
|
test_settings: {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
default: {
|
|
43
|
+
launch_url: 'http://webship.co',
|
|
44
|
+
selenium_port: 4444,
|
|
45
|
+
selenium_host: '127.0.0.1',
|
|
46
|
+
silent: true,
|
|
47
|
+
screenshots: {
|
|
48
|
+
enabled: true,
|
|
49
|
+
path: './reports/screenshots',
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
desiredCapabilities: {
|
|
53
|
+
browserName: 'chrome',
|
|
54
|
+
'goog:chromeOptions': {
|
|
55
|
+
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
|
|
56
|
+
//
|
|
57
|
+
// w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
|
|
58
|
+
w3c: false,
|
|
59
|
+
args: [
|
|
60
|
+
'--headless',
|
|
61
|
+
'--start-maximized',
|
|
62
|
+
'--disable-gpu',
|
|
63
|
+
'--window-size=1600,1200',
|
|
64
|
+
'--no-sandbox',
|
|
65
|
+
'--disable-dev-shm-usage',
|
|
66
|
+
'--disable-setuid-sandbox',
|
|
67
|
+
'--disable-web-security',
|
|
68
|
+
'--DNS-prefetch-disable',
|
|
69
|
+
'--disable-translate',
|
|
70
|
+
'--ignore-certificate-errors',
|
|
71
|
+
'--test-type',
|
|
72
|
+
'--disable-extensions',
|
|
73
|
+
'--incognito',
|
|
74
|
+
'--disable-infobars',
|
|
75
|
+
'--remote-debugging-port=9222',
|
|
76
|
+
'--allowed-ips=*',
|
|
77
|
+
'--whitelisted-ips=*',
|
|
78
|
+
'--allow-insecure-localhost',
|
|
79
|
+
],
|
|
50
80
|
},
|
|
51
|
-
|
|
52
|
-
desiredCapabilities: {
|
|
53
|
-
browserName: 'chrome',
|
|
54
|
-
'goog:chromeOptions': {
|
|
55
|
-
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
|
|
56
|
-
//
|
|
57
|
-
// w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
|
|
58
|
-
w3c: false,
|
|
59
|
-
args: [
|
|
60
|
-
'--headless',
|
|
61
|
-
'--start-maximized',
|
|
62
|
-
'--disable-gpu',
|
|
63
|
-
'--window-size=1600,1200',
|
|
64
|
-
'--no-sandbox',
|
|
65
|
-
'--disable-dev-shm-usage',
|
|
66
|
-
'--disable-setuid-sandbox',
|
|
67
|
-
'--disable-web-security',
|
|
68
|
-
'--DNS-prefetch-disable',
|
|
69
|
-
'--disable-translate',
|
|
70
|
-
'--ignore-certificate-errors',
|
|
71
|
-
'--test-type',
|
|
72
|
-
'--disable-extensions',
|
|
73
|
-
'--incognito',
|
|
74
|
-
'--disable-infobars',
|
|
75
|
-
'--remote-debugging-port=9222',
|
|
76
|
-
'--allowed-ips=*',
|
|
77
|
-
'--whitelisted-ips=*',
|
|
78
|
-
'--allow-insecure-localhost'
|
|
79
|
-
]
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
81
|
},
|
|
82
|
+
},
|
|
83
83
|
|
|
84
84
|
safari: {
|
|
85
85
|
desiredCapabilities: {
|
|
86
86
|
browserName: 'safari',
|
|
87
87
|
alwaysMatch: {
|
|
88
|
-
acceptInsecureCerts: false
|
|
89
|
-
}
|
|
88
|
+
acceptInsecureCerts: false,
|
|
89
|
+
},
|
|
90
90
|
},
|
|
91
91
|
webdriver: {
|
|
92
92
|
start_process: true,
|
|
93
|
-
server_path: ''
|
|
94
|
-
}
|
|
93
|
+
server_path: '',
|
|
94
|
+
},
|
|
95
95
|
},
|
|
96
96
|
|
|
97
97
|
firefox: {
|
|
@@ -103,9 +103,9 @@ module.exports = {
|
|
|
103
103
|
args: [
|
|
104
104
|
// '-headless',
|
|
105
105
|
// '-verbose'
|
|
106
|
-
]
|
|
107
|
-
}
|
|
108
|
-
}
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
109
|
},
|
|
110
110
|
webdriver: {
|
|
111
111
|
start_process: true,
|
|
@@ -113,8 +113,8 @@ module.exports = {
|
|
|
113
113
|
cli_args: [
|
|
114
114
|
// very verbose geckodriver logs
|
|
115
115
|
// '-vv'
|
|
116
|
-
]
|
|
117
|
-
}
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
118
|
},
|
|
119
119
|
|
|
120
120
|
chrome: {
|
|
@@ -126,12 +126,12 @@ module.exports = {
|
|
|
126
126
|
// w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
|
|
127
127
|
w3c: true,
|
|
128
128
|
args: [
|
|
129
|
-
//'--no-sandbox',
|
|
130
|
-
//'--ignore-certificate-errors',
|
|
131
|
-
//'--allow-insecure-localhost',
|
|
132
|
-
//'--headless'
|
|
133
|
-
]
|
|
134
|
-
}
|
|
129
|
+
// '--no-sandbox',
|
|
130
|
+
// '--ignore-certificate-errors',
|
|
131
|
+
// '--allow-insecure-localhost',
|
|
132
|
+
// '--headless'
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
135
|
},
|
|
136
136
|
|
|
137
137
|
webdriver: {
|
|
@@ -139,8 +139,8 @@ module.exports = {
|
|
|
139
139
|
server_path: '',
|
|
140
140
|
cli_args: [
|
|
141
141
|
// --verbose
|
|
142
|
-
]
|
|
143
|
-
}
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
144
|
},
|
|
145
145
|
|
|
146
146
|
edge: {
|
|
@@ -150,9 +150,9 @@ module.exports = {
|
|
|
150
150
|
w3c: true,
|
|
151
151
|
// More info on EdgeDriver: https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/capabilities-edge-options
|
|
152
152
|
args: [
|
|
153
|
-
//'--headless'
|
|
154
|
-
]
|
|
155
|
-
}
|
|
153
|
+
// '--headless'
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
156
|
},
|
|
157
157
|
|
|
158
158
|
webdriver: {
|
|
@@ -162,16 +162,16 @@ module.exports = {
|
|
|
162
162
|
server_path: '',
|
|
163
163
|
cli_args: [
|
|
164
164
|
// --verbose
|
|
165
|
-
]
|
|
166
|
-
}
|
|
165
|
+
],
|
|
166
|
+
},
|
|
167
167
|
},
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
/// ///////////////////////////////////////////////////////////////////////////////
|
|
170
170
|
// Configuration for when using cucumber-js (https://cucumber.io) |
|
|
171
171
|
// |
|
|
172
172
|
// It uses the bundled examples inside the nightwatch examples folder; feel free |
|
|
173
173
|
// to adapt this to your own project needs |
|
|
174
|
-
|
|
174
|
+
/// ///////////////////////////////////////////////////////////////////////////////
|
|
175
175
|
'cucumber-js': {
|
|
176
176
|
src_folders: ['examples/cucumber-js/features/step_definitions'],
|
|
177
177
|
|
|
@@ -181,56 +181,56 @@ module.exports = {
|
|
|
181
181
|
|
|
182
182
|
// define cucumber specific options
|
|
183
183
|
options: {
|
|
184
|
-
//set the feature path
|
|
185
|
-
feature_path: 'node_modules/nightwatch/examples/cucumber-js/*/*.feature'
|
|
184
|
+
// set the feature path
|
|
185
|
+
feature_path: 'node_modules/nightwatch/examples/cucumber-js/*/*.feature',
|
|
186
186
|
|
|
187
187
|
// start the webdriver session automatically (enabled by default)
|
|
188
188
|
// auto_start_session: true
|
|
189
189
|
|
|
190
190
|
// use parallel execution in Cucumber
|
|
191
191
|
// parallel: 2 // set number of workers to use (can also be defined in the cli as --parallel 2
|
|
192
|
-
}
|
|
193
|
-
}
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
194
|
},
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
/// ///////////////////////////////////////////////////////////////////////////////
|
|
197
197
|
// Configuration for when using the browserstack.com cloud service |
|
|
198
198
|
// |
|
|
199
199
|
// Please set the username and access key by setting the environment variables: |
|
|
200
200
|
// - BROWSERSTACK_USER |
|
|
201
201
|
// - BROWSERSTACK_KEY |
|
|
202
202
|
// .env files are supported |
|
|
203
|
-
|
|
203
|
+
/// ///////////////////////////////////////////////////////////////////////////////
|
|
204
204
|
browserstack: {
|
|
205
205
|
selenium: {
|
|
206
206
|
host: 'hub-cloud.browserstack.com',
|
|
207
|
-
port: 443
|
|
207
|
+
port: 443,
|
|
208
208
|
},
|
|
209
209
|
// More info on configuring capabilities can be found on:
|
|
210
210
|
// https://www.browserstack.com/automate/capabilities?tag=selenium-4
|
|
211
211
|
desiredCapabilities: {
|
|
212
212
|
'bstack:options': {
|
|
213
213
|
userName: '${BROWSERSTACK_USER}',
|
|
214
|
-
accessKey: '${BROWSERSTACK_KEY}'
|
|
215
|
-
}
|
|
214
|
+
accessKey: '${BROWSERSTACK_KEY}',
|
|
215
|
+
},
|
|
216
216
|
},
|
|
217
217
|
|
|
218
218
|
disable_error_log: true,
|
|
219
219
|
webdriver: {
|
|
220
220
|
timeout_options: {
|
|
221
221
|
timeout: 15000,
|
|
222
|
-
retry_attempts: 3
|
|
222
|
+
retry_attempts: 3,
|
|
223
223
|
},
|
|
224
224
|
keep_alive: true,
|
|
225
|
-
start_process: false
|
|
226
|
-
}
|
|
225
|
+
start_process: false,
|
|
226
|
+
},
|
|
227
227
|
},
|
|
228
228
|
|
|
229
229
|
'browserstack.local': {
|
|
230
230
|
extends: 'browserstack',
|
|
231
231
|
desiredCapabilities: {
|
|
232
|
-
'browserstack.local': true
|
|
233
|
-
}
|
|
232
|
+
'browserstack.local': true,
|
|
233
|
+
},
|
|
234
234
|
},
|
|
235
235
|
|
|
236
236
|
'browserstack.chrome': {
|
|
@@ -238,50 +238,50 @@ module.exports = {
|
|
|
238
238
|
desiredCapabilities: {
|
|
239
239
|
browserName: 'chrome',
|
|
240
240
|
chromeOptions: {
|
|
241
|
-
w3c: true
|
|
242
|
-
}
|
|
243
|
-
}
|
|
241
|
+
w3c: true,
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
244
|
},
|
|
245
245
|
|
|
246
246
|
'browserstack.firefox': {
|
|
247
247
|
extends: 'browserstack',
|
|
248
248
|
desiredCapabilities: {
|
|
249
|
-
browserName: 'firefox'
|
|
250
|
-
}
|
|
249
|
+
browserName: 'firefox',
|
|
250
|
+
},
|
|
251
251
|
},
|
|
252
252
|
|
|
253
253
|
'browserstack.ie': {
|
|
254
254
|
extends: 'browserstack',
|
|
255
255
|
desiredCapabilities: {
|
|
256
256
|
browserName: 'internet explorer',
|
|
257
|
-
browserVersion: '11.0'
|
|
258
|
-
}
|
|
257
|
+
browserVersion: '11.0',
|
|
258
|
+
},
|
|
259
259
|
},
|
|
260
260
|
|
|
261
261
|
'browserstack.safari': {
|
|
262
262
|
extends: 'browserstack',
|
|
263
263
|
desiredCapabilities: {
|
|
264
|
-
browserName: 'safari'
|
|
265
|
-
}
|
|
264
|
+
browserName: 'safari',
|
|
265
|
+
},
|
|
266
266
|
},
|
|
267
267
|
|
|
268
268
|
'browserstack.local_chrome': {
|
|
269
269
|
extends: 'browserstack.local',
|
|
270
270
|
desiredCapabilities: {
|
|
271
|
-
browserName: 'chrome'
|
|
272
|
-
}
|
|
271
|
+
browserName: 'chrome',
|
|
272
|
+
},
|
|
273
273
|
},
|
|
274
274
|
|
|
275
275
|
'browserstack.local_firefox': {
|
|
276
276
|
extends: 'browserstack.local',
|
|
277
277
|
desiredCapabilities: {
|
|
278
|
-
browserName: 'firefox'
|
|
279
|
-
}
|
|
278
|
+
browserName: 'firefox',
|
|
279
|
+
},
|
|
280
280
|
},
|
|
281
|
-
|
|
281
|
+
/// ///////////////////////////////////////////////////////////////////////////////
|
|
282
282
|
// Configuration for when using the Selenium service, either locally or remote, |
|
|
283
283
|
// like Selenium Grid |
|
|
284
|
-
|
|
284
|
+
/// ///////////////////////////////////////////////////////////////////////////////
|
|
285
285
|
selenium_server: {
|
|
286
286
|
// Selenium Server is running locally and is managed by Nightwatch
|
|
287
287
|
selenium: {
|
|
@@ -290,9 +290,9 @@ module.exports = {
|
|
|
290
290
|
server_path: (Services.seleniumServer ? Services.seleniumServer.path : ''),
|
|
291
291
|
cli_args: {
|
|
292
292
|
'webdriver.gecko.driver': (Services.geckodriver ? Services.geckodriver.path : ''),
|
|
293
|
-
'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : '')
|
|
294
|
-
}
|
|
295
|
-
}
|
|
293
|
+
'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : ''),
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
296
|
},
|
|
297
297
|
|
|
298
298
|
'selenium.chrome': {
|
|
@@ -300,9 +300,9 @@ module.exports = {
|
|
|
300
300
|
desiredCapabilities: {
|
|
301
301
|
browserName: 'chrome',
|
|
302
302
|
chromeOptions: {
|
|
303
|
-
w3c: true
|
|
304
|
-
}
|
|
305
|
-
}
|
|
303
|
+
w3c: true,
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
306
|
},
|
|
307
307
|
|
|
308
308
|
'selenium.firefox': {
|
|
@@ -313,11 +313,11 @@ module.exports = {
|
|
|
313
313
|
args: [
|
|
314
314
|
// '-headless',
|
|
315
315
|
// '-verbose'
|
|
316
|
-
]
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
316
|
+
],
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
321
|
};
|
|
322
322
|
|
|
323
323
|
function loadServices() {
|
package/package.json
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webship-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Webship JS automated functional testing.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
7
7
|
"test": "test"
|
|
8
8
|
},
|
|
9
|
+
"engines": {
|
|
10
|
+
"yarn": ">= 1.6",
|
|
11
|
+
"node": ">= 16.0"
|
|
12
|
+
},
|
|
9
13
|
"scripts": {
|
|
10
|
-
"test": "nightwatch --format @cucumber/pretty-formatter --format-options '{\"colorsEnabled\": true}' --format-options '{\"theme\": {\"feature keyword\":[\"bold\",\"blue\"],\"feature name\":[\"blue\",\"underline\"],\"feature description\":[\"blueBright\"],\"scenario keyword\":[\"bold\",\"magenta\"],\"scenario name\":[\"magenta\",\"underline\"],\"step keyword\":[\"bold\",\"green\"],\"step text\":[\"greenBright\",\"italic\"]}}' --format json:./tests/reports/cucumber-report-$( date '+%Y-%m-%d_%H-%M' ).json --format html:./tests/reports/cucumber-report-$( date '+%Y-%m-%d_%H-%M' ).html"
|
|
14
|
+
"test": "nightwatch --format @cucumber/pretty-formatter --format-options '{\"colorsEnabled\": true}' --format-options '{\"theme\": {\"feature keyword\":[\"bold\",\"blue\"],\"feature name\":[\"blue\",\"underline\"],\"feature description\":[\"blueBright\"],\"scenario keyword\":[\"bold\",\"magenta\"],\"scenario name\":[\"magenta\",\"underline\"],\"step keyword\":[\"bold\",\"green\"],\"step text\":[\"greenBright\",\"italic\"]}}' --format json:./tests/reports/cucumber-report-$( date '+%Y-%m-%d_%H-%M' ).json --format html:./tests/reports/cucumber-report-$( date '+%Y-%m-%d_%H-%M' ).html",
|
|
15
|
+
"lint:js": "node ./node_modules/eslint/bin/eslint.js --config=.eslintrc.json ."
|
|
11
16
|
},
|
|
12
17
|
"repository": {
|
|
13
18
|
"type": "git",
|
|
@@ -23,9 +28,15 @@
|
|
|
23
28
|
"@cucumber/cucumber": "*",
|
|
24
29
|
"@cucumber/pretty-formatter": "^1.0.0-alpha.2",
|
|
25
30
|
"chromedriver": "*",
|
|
26
|
-
"eslint": "^7.32.0",
|
|
27
31
|
"geckodriver": "*",
|
|
32
|
+
"eslint": "~8.0",
|
|
33
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
34
|
+
"eslint-plugin-import": "^2.25.4",
|
|
28
35
|
"mocha": "^9.1.3",
|
|
29
36
|
"nightwatch": "^2.1.7"
|
|
30
|
-
}
|
|
37
|
+
},
|
|
38
|
+
"bin":{
|
|
39
|
+
"webship-js-dl" : "./bin/webship-js-dl.js",
|
|
40
|
+
"webship-js-di" : "./bin/webship-js-di.js"
|
|
41
|
+
}
|
|
31
42
|
}
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
const {Given} = require('@cucumber/cucumber');
|
|
2
|
-
const {When, Before} = require('@cucumber/cucumber');
|
|
3
|
-
const {Then} = require('@cucumber/cucumber');
|
|
1
|
+
const { Given } = require('@cucumber/cucumber');
|
|
2
|
+
const { When, Before } = require('@cucumber/cucumber');
|
|
3
|
+
const { Then } = require('@cucumber/cucumber');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* webship.js step definitions
|
|
7
|
+
* inside webship-js backage
|
|
8
8
|
*/
|
|
9
|
-
Given(/^I go to "([^"]*)?"$/,
|
|
10
|
-
return browser.url(url);
|
|
11
|
-
});
|
|
9
|
+
Given(/^I go to "([^"]*)?"$/, (url) => browser.url(url));
|
|
12
10
|
|
|
13
|
-
Then(/^I should( not)* see "([^"]*)?"$/,
|
|
11
|
+
Then(/^I should( not)* see "([^"]*)?"$/, (negativeCase, expectedText) => {
|
|
14
12
|
if (negativeCase) {
|
|
15
13
|
return browser.assert.not.textContains('body', expectedText);
|
|
16
14
|
}
|
|
17
|
-
|
|
15
|
+
|
|
18
16
|
return browser.assert.textContains('body', expectedText);
|
|
19
17
|
});
|
|
20
|
-
|
|
21
|
-
|
package/bin/webship-js-di
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
conf = require("./../nightwatch.conf.js");
|
|
5
|
-
const FoldersPath = conf.src_folders;
|
|
6
|
-
|
|
7
|
-
// console.log(process.argv);
|
|
8
|
-
|
|
9
|
-
for(var i=2; i<process.argv.length; i++)
|
|
10
|
-
FoldersPath.push(process.argv[i]);
|
|
11
|
-
|
|
12
|
-
FoldersPath.forEach(Folder_Path => {
|
|
13
|
-
|
|
14
|
-
fs.readdir(Folder_Path, function (err, files) {
|
|
15
|
-
|
|
16
|
-
if (err) {
|
|
17
|
-
return console.log('Unable to scan directory: ' + err);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
files.forEach(file => {
|
|
21
|
-
fs.readFile('./' + Folder_Path + '/' + file, 'utf8', (err, data) => {
|
|
22
|
-
if(err){
|
|
23
|
-
throw new Error(err);
|
|
24
|
-
}
|
|
25
|
-
const SplitByLine_Arr = data.split("\n");
|
|
26
|
-
const Trim_Arr = SplitByLine_Arr.map(element => {
|
|
27
|
-
return element.trim();
|
|
28
|
-
});
|
|
29
|
-
const StartWith_Arr = Trim_Arr.filter(StartWith);
|
|
30
|
-
const Steps_Arr = CleanStepsList(StartWith_Arr);
|
|
31
|
-
|
|
32
|
-
Steps_Arr.forEach(element => {
|
|
33
|
-
console.log(element);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Start with Function.
|
|
42
|
-
*
|
|
43
|
-
* Return list of array items start with (Given, Then, When,*).
|
|
44
|
-
*
|
|
45
|
-
* @param ArrLine
|
|
46
|
-
* @returns array
|
|
47
|
-
*/
|
|
48
|
-
function StartWith(ArrLine) {
|
|
49
|
-
return (ArrLine.startsWith('Given')
|
|
50
|
-
|| ArrLine.startsWith('Then')
|
|
51
|
-
|| ArrLine.startsWith('When')
|
|
52
|
-
|| ArrLine.startsWith('*'));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Clean Steps List
|
|
57
|
-
*
|
|
58
|
-
* Return list of array items cleand from unreadable chars
|
|
59
|
-
*
|
|
60
|
-
* @param ListArr
|
|
61
|
-
* @returns
|
|
62
|
-
*/
|
|
63
|
-
function CleanStepsList(ListArr) {
|
|
64
|
-
var StepComment = '';
|
|
65
|
-
var NewArr = Array();
|
|
66
|
-
|
|
67
|
-
ListArr.forEach((element, index) => {
|
|
68
|
-
|
|
69
|
-
if(element.startsWith("* ")){
|
|
70
|
-
StepComment = StepComment + element.substring(2) + '\r\n';
|
|
71
|
-
}
|
|
72
|
-
else if(element.startsWith("/**") || element.startsWith("*/")){
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
else
|
|
76
|
-
{
|
|
77
|
-
const Filter1 = element.split("$/");
|
|
78
|
-
const Filter2 = Filter1[0].replace("(/^", ' ');
|
|
79
|
-
|
|
80
|
-
NewArr.push(Filter2 + '\r\n' + StepComment);
|
|
81
|
-
StepComment = '';
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
});
|
|
85
|
-
return NewArr;
|
|
86
|
-
}
|
|
87
|
-
|
package/bin/webship-js-dl
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
|
|
5
|
-
conf = require("./../nightwatch.conf.js");
|
|
6
|
-
var FoldersPath = conf.src_folders;
|
|
7
|
-
|
|
8
|
-
for(var i=2; i<process.argv.length; i++)
|
|
9
|
-
FoldersPath.push(process.argv[i]);
|
|
10
|
-
|
|
11
|
-
FoldersPath.forEach(Folder_Path => {
|
|
12
|
-
|
|
13
|
-
fs.readdir(Folder_Path, function (err, files) {
|
|
14
|
-
|
|
15
|
-
if (err) {
|
|
16
|
-
return console.log('Unable to scan directory: ' + err);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
files.forEach(file => {
|
|
20
|
-
fs.readFile('./' + Folder_Path + '/' + file, 'utf8', (err, data) => {
|
|
21
|
-
if(err){
|
|
22
|
-
throw new Error(err);
|
|
23
|
-
}
|
|
24
|
-
const SplitByLine_Arr = data.split("\n");
|
|
25
|
-
const Trim_Arr = SplitByLine_Arr.map(element => {
|
|
26
|
-
return element.trim();
|
|
27
|
-
});
|
|
28
|
-
const StartWith_Arr = Trim_Arr.filter(StartWith);
|
|
29
|
-
const Steps_Arr = CleanStepsList(StartWith_Arr);
|
|
30
|
-
|
|
31
|
-
Steps_Arr.forEach(element => {
|
|
32
|
-
console.log(element);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Start with Function.
|
|
41
|
-
*
|
|
42
|
-
* Return list of array items start with (Given, Then, When).
|
|
43
|
-
*
|
|
44
|
-
* @param ArrLine
|
|
45
|
-
* @returns array
|
|
46
|
-
*/
|
|
47
|
-
function StartWith(ArrLine) {
|
|
48
|
-
return (ArrLine.startsWith('Given')
|
|
49
|
-
|| ArrLine.startsWith('Then')
|
|
50
|
-
|| ArrLine.startsWith('When'));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Clean Steps List
|
|
55
|
-
*
|
|
56
|
-
* Return list of array items cleand from unreadable chars
|
|
57
|
-
*
|
|
58
|
-
* @param ListArr
|
|
59
|
-
* @returns
|
|
60
|
-
*/
|
|
61
|
-
function CleanStepsList(ListArr) {
|
|
62
|
-
ListArr.forEach((element, index) => {
|
|
63
|
-
const Filter1 = element.split("$/");
|
|
64
|
-
const Filter2 = Filter1[0].replace("(/^", ' ');
|
|
65
|
-
|
|
66
|
-
ListArr[index] = Filter2;
|
|
67
|
-
});
|
|
68
|
-
return Arr;
|
|
69
|
-
}
|
|
70
|
-
|