artes 1.0.59 → 1.0.61
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/package.json
CHANGED
|
@@ -7,9 +7,8 @@ function runTests(args, flags) {
|
|
|
7
7
|
|
|
8
8
|
const featureFiles = args[args.indexOf("--features") + 1];
|
|
9
9
|
const features = flags.features && featureFiles;
|
|
10
|
-
|
|
11
|
-
const tags = args[args.indexOf("--tags") + 1];
|
|
12
10
|
|
|
11
|
+
const tags = args[args.indexOf("--tags") + 1];
|
|
13
12
|
|
|
14
13
|
flags.env && console.log("Running env:", env);
|
|
15
14
|
flags.env ? (process.env.ENV = JSON.stringify(env)) : "";
|
|
@@ -2,17 +2,19 @@ const { addElements } = require("./elementController");
|
|
|
2
2
|
const cucumberConfig = require("../../../cucumber.config");
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
function pomCollector() {
|
|
5
|
-
fs.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
if (fs.existsSync(cucumberConfig.default.pomPath)) {
|
|
6
|
+
fs.readdir(`${cucumberConfig.default.pomPath}`, (err, files) => {
|
|
7
|
+
files.forEach((file) => {
|
|
8
|
+
fs.readFile(
|
|
9
|
+
`${cucumberConfig.default.pomPath}/${file}`,
|
|
10
|
+
"utf-8",
|
|
11
|
+
(err, content) => {
|
|
12
|
+
addElements(JSON.parse(content));
|
|
13
|
+
},
|
|
14
|
+
);
|
|
15
|
+
});
|
|
14
16
|
});
|
|
15
|
-
}
|
|
17
|
+
}
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
module.exports = { pomCollector };
|
|
@@ -51,7 +51,6 @@ function processForm(key, value) {
|
|
|
51
51
|
value.endsWith(".docx") ||
|
|
52
52
|
value.includes("/"))
|
|
53
53
|
) {
|
|
54
|
-
// If it looks like a file path, treat it as a file
|
|
55
54
|
try {
|
|
56
55
|
if (fs.existsSync(value)) {
|
|
57
56
|
formData[key] = {
|
|
@@ -61,41 +60,72 @@ function processForm(key, value) {
|
|
|
61
60
|
};
|
|
62
61
|
return;
|
|
63
62
|
}
|
|
64
|
-
} catch (error) {
|
|
65
|
-
// If file doesn't exist, treat as regular string
|
|
66
|
-
}
|
|
63
|
+
} catch (error) {}
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
return formData;
|
|
70
67
|
}
|
|
71
68
|
|
|
69
|
+
async function requestMaker(headers, data, requestDataType) {
|
|
70
|
+
let request = {};
|
|
71
|
+
|
|
72
|
+
Object.assign(request, { headers: headers });
|
|
73
|
+
|
|
74
|
+
switch (requestDataType) {
|
|
75
|
+
case "multipart":
|
|
76
|
+
Object.assign(request, { multipart: data });
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
Object.assign(request, { data: data });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return request;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function responseMaker(request, response) {
|
|
86
|
+
const responseObject = {};
|
|
87
|
+
|
|
88
|
+
response && Object.assign(responseObject, { URL: response.url() });
|
|
89
|
+
|
|
90
|
+
request.headers &&
|
|
91
|
+
Object.assign(responseObject, { "Request Headers": await request.headers });
|
|
92
|
+
|
|
93
|
+
request.body &&
|
|
94
|
+
Object.assign(responseObject, { "Request Body": await request.body });
|
|
95
|
+
|
|
96
|
+
response && Object.assign(responseObject, { Response: await response });
|
|
97
|
+
|
|
98
|
+
response &&
|
|
99
|
+
Object.assign(responseObject, {
|
|
100
|
+
"Response Headers": await response.headers(),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
if (response) {
|
|
104
|
+
try {
|
|
105
|
+
Object.assign(responseObject, { "Response Body": await response.json() });
|
|
106
|
+
} catch (e) {
|
|
107
|
+
Object.assign(responseObject, { "Response Body": await response.text() });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return responseObject;
|
|
112
|
+
}
|
|
113
|
+
|
|
72
114
|
const api = {
|
|
73
115
|
get: async (url, payload) => {
|
|
74
116
|
const URL = await selector(url);
|
|
75
117
|
const resolvedURL = await resolveVariable(URL);
|
|
76
118
|
|
|
77
|
-
const resolvedPayload = resolveVariable(payload);
|
|
119
|
+
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
78
120
|
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
79
121
|
|
|
80
|
-
const
|
|
81
|
-
headers: payloadJSON ? payloadJSON.headers : {},
|
|
82
|
-
});
|
|
122
|
+
const req = await requestMaker(payloadJSON?.headers || {});
|
|
83
123
|
|
|
84
|
-
|
|
85
|
-
const header = await res.headers();
|
|
86
|
-
const body = await res.json();
|
|
87
|
-
|
|
88
|
-
const response = {
|
|
89
|
-
url: res.url(),
|
|
90
|
-
response: res,
|
|
91
|
-
responseHeaders: header,
|
|
92
|
-
responseBody: body,
|
|
93
|
-
};
|
|
124
|
+
const res = await context.request.get(resolvedURL, req);
|
|
94
125
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
126
|
+
const response = responseMaker(payloadJSON, res);
|
|
127
|
+
|
|
128
|
+
context.response = await response;
|
|
99
129
|
},
|
|
100
130
|
head: async (url) => {
|
|
101
131
|
const URL = await selector(url);
|
|
@@ -103,188 +133,135 @@ const api = {
|
|
|
103
133
|
|
|
104
134
|
const res = await context.request.head(resolvedURL);
|
|
105
135
|
|
|
106
|
-
|
|
107
|
-
const header = await res.headers();
|
|
136
|
+
const response = responseMaker(payloadJSON, res);
|
|
108
137
|
|
|
109
|
-
|
|
110
|
-
url: res.url(),
|
|
111
|
-
response: res,
|
|
112
|
-
responseHeaders: header,
|
|
113
|
-
responseBody: body,
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
context.response = response;
|
|
117
|
-
} catch (error) {
|
|
118
|
-
throw new Error(`Error processing response: ${error.message}`);
|
|
119
|
-
}
|
|
138
|
+
context.response = await response;
|
|
120
139
|
},
|
|
121
|
-
post: async (url, payload,
|
|
140
|
+
post: async (url, payload, requestDataType) => {
|
|
122
141
|
const URL = await selector(url);
|
|
123
142
|
const resolvedURL = await resolveVariable(URL);
|
|
124
143
|
|
|
125
|
-
const resolvedPayload = await resolveVariable(payload);
|
|
144
|
+
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
126
145
|
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
127
146
|
|
|
128
|
-
let
|
|
147
|
+
let req;
|
|
129
148
|
|
|
130
|
-
switch (
|
|
149
|
+
switch (requestDataType) {
|
|
131
150
|
case "multipart":
|
|
132
151
|
let combinedFormData = {};
|
|
152
|
+
|
|
133
153
|
for (const [key, value] of Object.entries(payloadJSON.body)) {
|
|
134
154
|
const formData = processForm(key, value);
|
|
135
155
|
Object.assign(combinedFormData, formData);
|
|
136
156
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
157
|
+
|
|
158
|
+
req = await requestMaker(
|
|
159
|
+
payloadJSON.headers || {},
|
|
160
|
+
combinedFormData || {},
|
|
161
|
+
requestDataType,
|
|
162
|
+
);
|
|
141
163
|
break;
|
|
142
164
|
default:
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
165
|
+
req = await requestMaker(
|
|
166
|
+
payloadJSON.headers || {},
|
|
167
|
+
payloadJSON.body || {},
|
|
168
|
+
);
|
|
147
169
|
}
|
|
148
170
|
|
|
149
|
-
const res = await context.request.post(resolvedURL,
|
|
171
|
+
const res = await context.request.post(resolvedURL, req);
|
|
150
172
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const response = {
|
|
156
|
-
url: res.url(),
|
|
157
|
-
requestHeaders: payloadJSON.headers,
|
|
158
|
-
requestBody: payloadJSON.body,
|
|
159
|
-
response: res,
|
|
160
|
-
responseHeaders: header,
|
|
161
|
-
responseBody: body,
|
|
162
|
-
};
|
|
163
|
-
context.response = response;
|
|
164
|
-
} catch (error) {
|
|
165
|
-
throw new Error(`Error processing response: ${error.message}`);
|
|
166
|
-
}
|
|
173
|
+
const response = await responseMaker(payloadJSON, res);
|
|
174
|
+
|
|
175
|
+
context.response = await response;
|
|
167
176
|
},
|
|
168
|
-
put: async (url, payload,
|
|
177
|
+
put: async (url, payload, requestDataType) => {
|
|
169
178
|
const URL = await selector(url);
|
|
170
179
|
const resolvedURL = await resolveVariable(URL);
|
|
171
180
|
|
|
172
|
-
const resolvedPayload = await resolveVariable(payload);
|
|
181
|
+
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
173
182
|
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
174
183
|
|
|
175
|
-
let
|
|
184
|
+
let req;
|
|
176
185
|
|
|
177
|
-
switch (
|
|
186
|
+
switch (requestDataType) {
|
|
178
187
|
case "multipart":
|
|
179
188
|
let combinedFormData = {};
|
|
180
189
|
for (const [key, value] of Object.entries(payloadJSON.body)) {
|
|
181
190
|
const formData = processForm(key, value);
|
|
182
191
|
Object.assign(combinedFormData, formData);
|
|
183
192
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
193
|
+
|
|
194
|
+
req = await requestMaker(
|
|
195
|
+
payloadJSON.headers || {},
|
|
196
|
+
combinedFormData || {},
|
|
197
|
+
requestDataType,
|
|
198
|
+
);
|
|
199
|
+
|
|
188
200
|
break;
|
|
189
201
|
default:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
202
|
+
req = await requestMaker(
|
|
203
|
+
payloadJSON.headers || {},
|
|
204
|
+
payloadJSON.body || {},
|
|
205
|
+
);
|
|
194
206
|
}
|
|
195
207
|
|
|
196
|
-
const res = await context.request.put(resolvedURL,
|
|
208
|
+
const res = await context.request.put(resolvedURL, req);
|
|
197
209
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const response = {
|
|
203
|
-
url: res.url(),
|
|
204
|
-
requestHeaders: payloadJSON.headers,
|
|
205
|
-
requestBody: payloadJSON.body,
|
|
206
|
-
response: res,
|
|
207
|
-
responseHeaders: header,
|
|
208
|
-
responseBody: body,
|
|
209
|
-
};
|
|
210
|
-
context.response = response;
|
|
211
|
-
} catch (error) {
|
|
212
|
-
throw new Error(`Error processing response: ${error.message}`);
|
|
213
|
-
}
|
|
210
|
+
const response = await responseMaker(payloadJSON, res);
|
|
211
|
+
|
|
212
|
+
context.response = await response;
|
|
214
213
|
},
|
|
215
|
-
patch: async (url, payload,
|
|
214
|
+
patch: async (url, payload, requestDataType) => {
|
|
216
215
|
const URL = await selector(url);
|
|
217
216
|
const resolvedURL = await resolveVariable(URL);
|
|
218
217
|
|
|
219
|
-
const resolvedPayload = await resolveVariable(payload);
|
|
218
|
+
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
220
219
|
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
221
220
|
|
|
222
|
-
let
|
|
221
|
+
let req;
|
|
223
222
|
|
|
224
|
-
switch (
|
|
223
|
+
switch (requestDataType) {
|
|
225
224
|
case "multipart":
|
|
226
225
|
let combinedFormData = {};
|
|
227
226
|
for (const [key, value] of Object.entries(payloadJSON.body)) {
|
|
228
227
|
const formData = processForm(key, value);
|
|
229
228
|
Object.assign(combinedFormData, formData);
|
|
230
229
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
230
|
+
|
|
231
|
+
req = await requestMaker(
|
|
232
|
+
payloadJSON.headers || {},
|
|
233
|
+
combinedFormData || {},
|
|
234
|
+
requestDataType,
|
|
235
|
+
);
|
|
236
|
+
|
|
235
237
|
break;
|
|
236
238
|
default:
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
239
|
+
req = await requestMaker(
|
|
240
|
+
payloadJSON.headers || {},
|
|
241
|
+
payloadJSON.body || {},
|
|
242
|
+
);
|
|
241
243
|
}
|
|
242
244
|
|
|
243
|
-
const res = await context.request.patch(resolvedURL,
|
|
245
|
+
const res = await context.request.patch(resolvedURL, req);
|
|
244
246
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const response = {
|
|
250
|
-
url: res.url(),
|
|
251
|
-
requestHeaders: payloadJSON.headers,
|
|
252
|
-
requestBody: payloadJSON.body,
|
|
253
|
-
response: res,
|
|
254
|
-
responseHeaders: header,
|
|
255
|
-
responseBody: body,
|
|
256
|
-
};
|
|
257
|
-
context.response = response;
|
|
258
|
-
} catch (error) {
|
|
259
|
-
throw new Error(`Error processing response: ${error.message}`);
|
|
260
|
-
}
|
|
247
|
+
const response = responseMaker(payloadJSON, res);
|
|
248
|
+
|
|
249
|
+
context.response = await response;
|
|
261
250
|
},
|
|
262
251
|
delete: async (url, payload) => {
|
|
263
252
|
const URL = await selector(url);
|
|
264
253
|
const resolvedURL = await resolveVariable(URL);
|
|
265
254
|
|
|
266
|
-
const resolvedPayload = await resolveVariable(payload);
|
|
255
|
+
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
267
256
|
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
268
257
|
|
|
269
|
-
const
|
|
270
|
-
headers: payloadJSON.headers,
|
|
271
|
-
});
|
|
258
|
+
const req = await requestMaker(payloadJSON.headers || {});
|
|
272
259
|
|
|
273
|
-
|
|
274
|
-
const header = await res.headers();
|
|
275
|
-
const body = await res.json();
|
|
276
|
-
|
|
277
|
-
const response = {
|
|
278
|
-
url: res.url(),
|
|
279
|
-
response: res,
|
|
280
|
-
responseHeaders: header,
|
|
281
|
-
responseBody: body,
|
|
282
|
-
};
|
|
260
|
+
const res = await context.request.delete(resolvedURL, req);
|
|
283
261
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
262
|
+
const response = responseMaker(payloadJSON, res);
|
|
263
|
+
|
|
264
|
+
context.response = await response;
|
|
288
265
|
},
|
|
289
266
|
vars: () => {
|
|
290
267
|
return context.vars;
|
package/src/hooks/hooks.js
CHANGED
|
@@ -56,10 +56,12 @@ After(async function ({ pickle, result }) {
|
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
if (context.response) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
Object.entries(context.response).forEach(async ([key, value]) => {
|
|
60
|
+
await this.attach(
|
|
61
|
+
`${key}:\n${JSON.stringify(value, null, 2)}`,
|
|
62
|
+
"text/plain",
|
|
63
|
+
);
|
|
64
|
+
});
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
await context.page.close();
|