webship-js 1.0.9 → 1.0.11

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.
@@ -0,0 +1,66 @@
1
+ [
2
+ {
3
+ "description": "As a tester\nI want to be able to test the webship.co site\nSo that I know it is working",
4
+ "elements": [
5
+ {
6
+ "description": "",
7
+ "id": "example-test-for-webship-js;check-the-webship.co-site",
8
+ "keyword": "Scenario",
9
+ "line": 6,
10
+ "name": "Check the webship.co site",
11
+ "steps": [
12
+ {
13
+ "keyword": "Before",
14
+ "hidden": true,
15
+ "result": {
16
+ "status": "passed",
17
+ "duration": 3380158803
18
+ }
19
+ },
20
+ {
21
+ "arguments": [],
22
+ "keyword": "Given ",
23
+ "line": 7,
24
+ "name": "I go to \"https://webship.co\"",
25
+ "match": {
26
+ "location": "tests/step-definitions/webship.js:5"
27
+ },
28
+ "result": {
29
+ "status": "passed",
30
+ "duration": 716341770
31
+ }
32
+ },
33
+ {
34
+ "arguments": [],
35
+ "keyword": "Then ",
36
+ "line": 8,
37
+ "name": "I should see \"Webship.co\"",
38
+ "match": {
39
+ "location": "tests/step-definitions/webship.js:9"
40
+ },
41
+ "result": {
42
+ "status": "passed",
43
+ "duration": 109572978
44
+ }
45
+ },
46
+ {
47
+ "keyword": "After",
48
+ "hidden": true,
49
+ "result": {
50
+ "status": "passed",
51
+ "duration": 164629689
52
+ }
53
+ }
54
+ ],
55
+ "tags": [],
56
+ "type": "scenario"
57
+ }
58
+ ],
59
+ "id": "example-test-for-webship-js",
60
+ "line": 1,
61
+ "keyword": "Feature",
62
+ "name": "Example test for webship-js",
63
+ "tags": [],
64
+ "uri": "tests/features/check-webshipco-site.feature"
65
+ }
66
+ ]
@@ -0,0 +1,28 @@
1
+ const { Given } = require('@cucumber/cucumber');
2
+ const { When, Before } = require('@cucumber/cucumber');
3
+ const { Then } = require('@cucumber/cucumber');
4
+
5
+ /**
6
+ * Navigate to a url.
7
+ *
8
+ * Exmaple:
9
+ * - Given I go to "https://webship.co"
10
+ */
11
+ Given(/^I go to "([^"]*)?"$/, function(url) {
12
+ return browser.url(url);
13
+ });
14
+
15
+ /**
16
+ * Asserting a text in the page.
17
+ *
18
+ * Exmaple:
19
+ * - Then I should see "Welcome"
20
+ * - Then I should not see "Access denied"
21
+ */
22
+ Then(/^I should( not)* see "([^"]*)?"$/, function(negativeCase, expectedText) {
23
+ if (negativeCase) {
24
+ return browser.assert.not.textContains('body', expectedText);
25
+ }
26
+
27
+ return browser.assert.textContains('body', expectedText);
28
+ });
package/bin/steplist.js DELETED
@@ -1,208 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- const fs = require('fs');
5
- const conf = require('../nightwatch.conf.js');
6
-
7
- /**
8
- * -----------------------------------------------------
9
- * Parse arguments
10
- * -----------------------------------------------------
11
- */
12
- const { ArgumentParser } = require('argparse');
13
- const { version } = require('../package.json');
14
-
15
- const parser = new ArgumentParser({
16
- description: 'Argparse example'
17
- });
18
-
19
- parser.add_argument('-v', '--version', { action: 'version', version });
20
- parser.add_argument('-l', '--list',
21
- {
22
- help: 'Display step definitions list without information.',
23
- action: 'store_true',
24
- default: true,
25
- });
26
-
27
- parser.add_argument('-i', '--information',
28
- {
29
- help: 'Display step definitions list with information.',
30
- action: 'store_true',
31
- });
32
-
33
- parser.add_argument('-c', '--config',
34
- {
35
- help: 'Add your nightwatch config file, Example: -c="config.js" OR -c=config.js OR -c config.js',
36
- default: '../nightwatch.conf.js',
37
- });
38
-
39
- parser.add_argument('-s', '--src_folders',
40
- {
41
- help: 'Add your step definitions folder/s path, Example: -s="path/to/folder1" OR -s="path/to/folder1 path/to/folder2", You can add as much as you want of folder paths',
42
- default: "tests/step-definitions",
43
- });
44
-
45
- parser.add_argument('-f', '--format',
46
- {
47
- help: 'Choose step definitions list format style, just add a number. (1) stdout-space. (2) stdout-dashes. Example: -f=1 OR -f 2',
48
- default: "1",
49
- });
50
-
51
- var argsParse = parser.parse_args();
52
-
53
- /**
54
- * -----------------------------------------------------
55
- */
56
-
57
- /**
58
- * Folders Path Array variable
59
- *
60
- * Set and Get folders path exist in (--config) tag and
61
- * (--src_folder) tag added in nodejs command line.
62
- */
63
- let foldersPath = [];
64
- function setFoldersPath(value) {
65
- value.forEach((element) => {
66
- foldersPath.push(element);
67
- });
68
- }
69
-
70
- /**
71
- * Output Format name variable
72
- *
73
- * Set and Get Output Format exist in (--format) tag added
74
- * in nodejs command line.
75
- */
76
- let outputFormat = 'stdout-spaces';
77
- function setOutputFormat(value) { outputFormat = value; }
78
-
79
- /**
80
- * Start with Function.
81
- *
82
- * Return list of array items that start with
83
- * (Given, Then, When, /** ,* , *\).
84
- *
85
- * @param {array} stepsList The full step-definitions file lines list.
86
- * @return {array} The array has only lines startsWith words chosen.
87
- */
88
- function startWith(stepsList) {
89
- if(argsParse.information == true){
90
- return (stepsList.startsWith('Given') ||
91
- stepsList.startsWith('Then') ||
92
- stepsList.startsWith('When') ||
93
- stepsList.startsWith('/**') ||
94
- stepsList.startsWith('* ') ||
95
- stepsList.startsWith('*/'));
96
- }
97
- else if(argsParse.list == true){
98
- return (stepsList.startsWith('Given') ||
99
- stepsList.startsWith('Then') ||
100
- stepsList.startsWith('When'));
101
- }
102
- }
103
-
104
- /**
105
- * Filter Step Definitions
106
- *
107
- * @param {array} stepsList The step definitions array is sent to filter
108
- * by startsWith words chosen.
109
- * @return {array} Step definitions filtered array.
110
- */
111
- function callStartsWith(stepsList) {
112
- return stepsList.filter(startWith);
113
- }
114
-
115
- /**
116
- * Clean Steps List
117
- *
118
- * Return list of array items cleand from unreadable chars.
119
- *
120
- * @param {array} stepsList The step definitions array before
121
- * clean unreadable signs.
122
- * @return {array} The step definitions cleaned array.
123
- */
124
- function stepsCleanList(stepsList) {
125
- let stepComment = '';
126
- const newStepsList = [];
127
-
128
- stepsList.forEach((element) => {
129
- if (element.startsWith('* ')) {
130
- element = element.replace('* ', '');
131
-
132
- if (stepComment === '') stepComment = element;
133
- else stepComment = `${stepComment}\r\n${element}`;
134
- } else if (!element.startsWith('/**') && !element.startsWith('*/')) {
135
- const filter1 = element.split('$/');
136
- const filter2 = filter1[0].replace('(/^', ' ');
137
-
138
- if (stepComment !== '') {
139
- if (outputFormat.startsWith('html')) newStepsList.push(`${filter2}\r\n<div>${stepComment}</div>`);
140
- else newStepsList.push(`${filter2}\r\n${stepComment}`);
141
- } else newStepsList.push(filter2);
142
-
143
- stepComment = '';
144
- }
145
- });
146
- return newStepsList;
147
- }
148
-
149
- function srcFolderPaths(path) {
150
- const paths = path.split(' ');
151
-
152
- setFoldersPath(paths);
153
- }
154
-
155
- /**
156
- * "foldersPath" array
157
- *
158
- * Fill "foldersPath" array process, that has paths of
159
- * all folders contain step definitions js files.
160
- */
161
-
162
- const configPath = require(argsParse.config);
163
-
164
- let configPathsArray = [];
165
- configPathsArray = configPath.src_folders;
166
-
167
- setFoldersPath(configPathsArray);
168
-
169
- if (foldersPath.length === 0){
170
- srcFolderPaths(argsParse.src_folders);
171
- }
172
-
173
- setOutputFormat(argsParse.format);
174
-
175
- /**
176
- * Step definitions list
177
- *
178
- * Get clear step definitions list from js
179
- * step definitions files.
180
- */
181
- foldersPath.forEach((folderPath) => {
182
- fs.readdir(folderPath, (err, files) => {
183
- if (err) {
184
- return console.log(`Unable to scan directory: ${err}`);
185
- }
186
-
187
- files.forEach((file) => {
188
- fs.readFile(`./${folderPath}/${file}`, 'utf8', (err, data) => {
189
- if (err) {
190
- throw new Error(err);
191
- }
192
- const contentLines = data.split('\n');
193
- const contentTrimmed = contentLines.map((element) => element.trim());
194
-
195
- const stepsStartWith = callStartsWith(contentTrimmed);
196
- const stepsList = stepsCleanList(stepsStartWith);
197
-
198
- stepsList.forEach((element) => {
199
- if (argsParse.format == 1) {
200
- console.log(element + '\n');
201
- } else if (argsParse.format == 2) {
202
- console.log(element + '\n');
203
- }
204
- });
205
- });
206
- });
207
- });
208
- });