artes 1.1.5 → 1.1.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/README.md +1 -0
- package/cucumber.config.js +2 -0
- package/executer.js +5 -0
- package/package.json +1 -1
- package/src/helper/stepFunctions/APIActions.js +68 -72
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ npx artes [options]
|
|
|
51
51
|
| 📊 `-r, --report` | Run tests and generate Allure report | `artes -r` or `artes --report` |
|
|
52
52
|
| `--reportSuccess` | Add screenshots and video records for also Success test cases | `artes --reportSuccess`|
|
|
53
53
|
| 📁 `--features` | Specify one or more feature files' relative paths to run (comma-separated) | `artes --features "tests/features/Alma,tests/features/Banan.feature"` |
|
|
54
|
+
| 📜 `--stepDef` | Specify one or more step definition files' relative paths to use (comma-separated) | `artes --stepDef "tests/steps/login.js,tests/steps/home.js"` |
|
|
54
55
|
| 🔖 `--tags` | Run tests with specified Cucumber tags | `artes --tags "@smoke or @wip"` |
|
|
55
56
|
| 🌐 `--env` | Set the environment for the test run | `artes --env "dev"` |
|
|
56
57
|
| 🕶️ `--headless` | Run browser in headless mode | `artes --headless` |
|
package/cucumber.config.js
CHANGED
|
@@ -45,6 +45,8 @@ module.exports = {
|
|
|
45
45
|
? path.join(moduleConfig.projectPath, artesConfig.features)
|
|
46
46
|
: [moduleConfig.featuresPath], // Paths to feature files
|
|
47
47
|
require: [
|
|
48
|
+
process.env.STEP_DEFINITIONS ?
|
|
49
|
+
[path.join(moduleConfig.projectPath, process.env.STEP_DEFINITIONS)] :
|
|
48
50
|
artesConfig.steps
|
|
49
51
|
? path.join(moduleConfig.projectPath, artesConfig.steps)
|
|
50
52
|
: moduleConfig.stepsPath,
|
package/executer.js
CHANGED
|
@@ -19,6 +19,7 @@ const flags = {
|
|
|
19
19
|
reportSuccess: args.includes("--reportSuccess"),
|
|
20
20
|
trace: args.includes("-t") || args.includes("--trace"),
|
|
21
21
|
features: args.includes("--features"),
|
|
22
|
+
stepDef: args.includes("--stepDef"),
|
|
22
23
|
tags: args.includes("--tags"),
|
|
23
24
|
env: args.includes("--env"),
|
|
24
25
|
headless: args.includes("--headless"),
|
|
@@ -38,6 +39,7 @@ const flags = {
|
|
|
38
39
|
const env = args[args.indexOf("--env") + 1];
|
|
39
40
|
const featureFiles = args[args.indexOf("--features") + 1];
|
|
40
41
|
const features = flags.features && featureFiles;
|
|
42
|
+
const stepDef = args[args.indexOf("--stepDef") + 1];
|
|
41
43
|
const tags = args[args.indexOf("--tags") + 1];
|
|
42
44
|
const parallel = args[args.indexOf("--parallel") + 1];
|
|
43
45
|
const retry = args[args.indexOf("--retry") + 1];
|
|
@@ -66,6 +68,9 @@ flags.tags ? (process.env.RUN_TAGS = JSON.stringify(tags)) : "";
|
|
|
66
68
|
flags.features && console.log("Running features:", features);
|
|
67
69
|
flags.features ? (process.env.FEATURES = features) : "";
|
|
68
70
|
|
|
71
|
+
flags.stepDef && console.log("Running step definitions:", flags.stepDef);
|
|
72
|
+
flags.stepDef ? (process.env.STEP_DEFINITIONS = stepDef) : "";
|
|
73
|
+
|
|
69
74
|
flags.headless &&
|
|
70
75
|
console.log("Running mode:", flags.headless ? "headless" : "headed");
|
|
71
76
|
flags.headless ? (process.env.MODE = JSON.stringify(true)) : false;
|
package/package.json
CHANGED
|
@@ -4,9 +4,10 @@ const {
|
|
|
4
4
|
context,
|
|
5
5
|
selector,
|
|
6
6
|
resolveVariable,
|
|
7
|
-
moduleConfig
|
|
7
|
+
moduleConfig
|
|
8
8
|
} = require("../imports/commons");
|
|
9
9
|
|
|
10
|
+
|
|
10
11
|
function getMimeType(filePath) {
|
|
11
12
|
const ext = path.extname(filePath).toLowerCase();
|
|
12
13
|
const mimeTypes = {
|
|
@@ -28,52 +29,59 @@ function getMimeType(filePath) {
|
|
|
28
29
|
return mimeTypes[ext] || "application/octet-stream";
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
function processForm(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
typeof value
|
|
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
|
-
|
|
32
|
+
function processForm( requestBody) {
|
|
33
|
+
for (const [key, value] of Object.entries(requestBody)) {
|
|
34
|
+
|
|
35
|
+
for (const item of value) {
|
|
36
|
+
if (typeof value === "object") {
|
|
37
|
+
if (value.contentType) {
|
|
38
|
+
const content =
|
|
39
|
+
typeof value.data === "object"
|
|
40
|
+
? JSON.stringify(value.data)
|
|
41
|
+
: String(value.data);
|
|
42
|
+
|
|
43
|
+
formData[key] = {
|
|
44
|
+
name: value.filename || key,
|
|
45
|
+
mimeType: value.contentType,
|
|
46
|
+
buffer: Buffer.from(content, "utf8"),
|
|
47
|
+
};
|
|
48
|
+
return;
|
|
49
|
+
} else {
|
|
50
|
+
formData[key] = JSON.stringify(value);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (
|
|
56
|
+
typeof value === "string" &&
|
|
57
|
+
(value.endsWith(".pdf") ||
|
|
58
|
+
value.endsWith(".jpg") ||
|
|
59
|
+
value.endsWith(".png") ||
|
|
60
|
+
value.endsWith(".txt") ||
|
|
61
|
+
value.endsWith(".doc") ||
|
|
62
|
+
value.endsWith(".docx") ||
|
|
63
|
+
value.includes("/"))
|
|
64
|
+
) {
|
|
65
|
+
try {
|
|
66
|
+
const filePath = path.join(moduleConfig.projectPath, value);
|
|
67
|
+
if (fs.existsSync(filePath)) {
|
|
68
|
+
formData[key] = {
|
|
69
|
+
name: path.basename(filePath),
|
|
70
|
+
mimeType: getMimeType(filePath),
|
|
71
|
+
buffer: fs.readFileSync(filePath),
|
|
72
|
+
};
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.log(error);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
formData[key] = value;
|
|
81
|
+
|
|
70
82
|
}
|
|
71
|
-
} catch (error) {
|
|
72
|
-
console.log(error);
|
|
73
83
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
formData[key] = value;
|
|
84
|
+
return formData;
|
|
77
85
|
}
|
|
78
86
|
|
|
79
87
|
async function requestMaker(headers, data, requestDataType) {
|
|
@@ -124,14 +132,12 @@ async function responseMaker(request, response, duration) {
|
|
|
124
132
|
}
|
|
125
133
|
|
|
126
134
|
|
|
127
|
-
|
|
128
135
|
return responseObject;
|
|
129
136
|
}
|
|
130
137
|
|
|
131
138
|
const api = {
|
|
132
139
|
get: async (url, payload) => {
|
|
133
140
|
const URL = await selector(url);
|
|
134
|
-
const resolvedURL = await resolveVariable(URL);
|
|
135
141
|
|
|
136
142
|
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
137
143
|
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
@@ -140,7 +146,7 @@ const api = {
|
|
|
140
146
|
|
|
141
147
|
const requestStarts = performance.now();
|
|
142
148
|
|
|
143
|
-
const res = await context.request.get(
|
|
149
|
+
const res = await context.request.get(URL[0], req);
|
|
144
150
|
|
|
145
151
|
const duration = performance.now() - requestStarts;
|
|
146
152
|
|
|
@@ -150,11 +156,10 @@ const api = {
|
|
|
150
156
|
},
|
|
151
157
|
head: async (url) => {
|
|
152
158
|
const URL = await selector(url);
|
|
153
|
-
const resolvedURL = await resolveVariable(URL);
|
|
154
159
|
|
|
155
160
|
const requestStarts = performance.now();
|
|
156
161
|
|
|
157
|
-
const res = await context.request.head(
|
|
162
|
+
const res = await context.request.head(URL[0]);
|
|
158
163
|
|
|
159
164
|
const duration = performance.now() - requestStarts;
|
|
160
165
|
|
|
@@ -164,7 +169,6 @@ const api = {
|
|
|
164
169
|
},
|
|
165
170
|
post: async (url, payload, requestDataType) => {
|
|
166
171
|
const URL = await selector(url);
|
|
167
|
-
const resolvedURL = await resolveVariable(URL);
|
|
168
172
|
|
|
169
173
|
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
170
174
|
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
@@ -173,15 +177,12 @@ const api = {
|
|
|
173
177
|
|
|
174
178
|
switch (requestDataType) {
|
|
175
179
|
case "multipart":
|
|
176
|
-
let formData = {};
|
|
177
180
|
|
|
178
|
-
|
|
179
|
-
processForm(formData, key, value);
|
|
180
|
-
}
|
|
181
|
+
const formRequest = processForm( payloadJSON?.body || {});
|
|
181
182
|
|
|
182
183
|
req = await requestMaker(
|
|
183
184
|
payloadJSON?.headers || {},
|
|
184
|
-
|
|
185
|
+
formRequest || {},
|
|
185
186
|
requestDataType,
|
|
186
187
|
);
|
|
187
188
|
break;
|
|
@@ -194,7 +195,7 @@ const api = {
|
|
|
194
195
|
|
|
195
196
|
const requestStarts = performance.now();
|
|
196
197
|
|
|
197
|
-
const res = await context.request.post(
|
|
198
|
+
const res = await context.request.post(URL[0], req);
|
|
198
199
|
|
|
199
200
|
const duration = performance.now() - requestStarts;
|
|
200
201
|
|
|
@@ -204,7 +205,6 @@ const api = {
|
|
|
204
205
|
},
|
|
205
206
|
put: async (url, payload, requestDataType) => {
|
|
206
207
|
const URL = await selector(url);
|
|
207
|
-
const resolvedURL = await resolveVariable(URL);
|
|
208
208
|
|
|
209
209
|
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
210
210
|
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
@@ -213,15 +213,14 @@ const api = {
|
|
|
213
213
|
|
|
214
214
|
switch (requestDataType) {
|
|
215
215
|
case "multipart":
|
|
216
|
-
let formData = {};
|
|
217
216
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
217
|
+
const formRequest = processForm( payloadJSON?.body || {});
|
|
218
|
+
|
|
219
|
+
|
|
221
220
|
|
|
222
221
|
req = await requestMaker(
|
|
223
222
|
payloadJSON?.headers || {},
|
|
224
|
-
|
|
223
|
+
formRequest || {},
|
|
225
224
|
requestDataType,
|
|
226
225
|
);
|
|
227
226
|
|
|
@@ -235,7 +234,7 @@ const api = {
|
|
|
235
234
|
|
|
236
235
|
const requestStarts = performance.now();
|
|
237
236
|
|
|
238
|
-
const res = await context.request.put(
|
|
237
|
+
const res = await context.request.put(URL[0], req);
|
|
239
238
|
|
|
240
239
|
const duration = performance.now() - requestStarts;
|
|
241
240
|
|
|
@@ -245,7 +244,6 @@ const api = {
|
|
|
245
244
|
},
|
|
246
245
|
patch: async (url, payload, requestDataType) => {
|
|
247
246
|
const URL = await selector(url);
|
|
248
|
-
const resolvedURL = await resolveVariable(URL);
|
|
249
247
|
|
|
250
248
|
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
251
249
|
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
@@ -256,13 +254,12 @@ const api = {
|
|
|
256
254
|
case "multipart":
|
|
257
255
|
let formData = {};
|
|
258
256
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
257
|
+
const formRequest = processForm( payloadJSON?.body || {});
|
|
258
|
+
|
|
262
259
|
|
|
263
260
|
req = await requestMaker(
|
|
264
261
|
payloadJSON?.headers || {},
|
|
265
|
-
|
|
262
|
+
formRequest || {},
|
|
266
263
|
requestDataType,
|
|
267
264
|
);
|
|
268
265
|
|
|
@@ -276,7 +273,7 @@ const api = {
|
|
|
276
273
|
|
|
277
274
|
const requestStarts = performance.now();
|
|
278
275
|
|
|
279
|
-
const res = await context.request.patch(
|
|
276
|
+
const res = await context.request.patch(URL[0], req);
|
|
280
277
|
|
|
281
278
|
const duration = performance.now() - requestStarts;
|
|
282
279
|
|
|
@@ -286,7 +283,6 @@ const api = {
|
|
|
286
283
|
},
|
|
287
284
|
delete: async (url, payload) => {
|
|
288
285
|
const URL = await selector(url);
|
|
289
|
-
const resolvedURL = await resolveVariable(URL);
|
|
290
286
|
|
|
291
287
|
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
292
288
|
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
@@ -297,7 +293,7 @@ const api = {
|
|
|
297
293
|
|
|
298
294
|
const requestStarts = performance.now();
|
|
299
295
|
|
|
300
|
-
const res = await context.request.delete(
|
|
296
|
+
const res = await context.request.delete(URL[0], req);
|
|
301
297
|
|
|
302
298
|
const duration = performance.now() - requestStarts;
|
|
303
299
|
|