artes 1.0.59 → 1.0.60

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artes",
3
- "version": "1.0.59",
3
+ "version": "1.0.60",
4
4
  "description": "The simplest way to automate UI and API tests using Cucumber-style steps.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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)) : "";
@@ -81,21 +81,23 @@ const api = {
81
81
  headers: payloadJSON ? payloadJSON.headers : {},
82
82
  });
83
83
 
84
+ const header = await res.headers();
85
+ let body;
84
86
  try {
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
- };
94
-
95
- context.response = response;
96
- } catch (error) {
97
- throw new Error(`Error processing response: ${error.message}`);
87
+ body = await res.json();
88
+ } catch (e) {
89
+ body = await res.text();
98
90
  }
91
+
92
+ const response = {
93
+ url: res.url(),
94
+ requestHeaders: payloadJSON.headers,
95
+ response: res,
96
+ responseHeaders: header,
97
+ responseBody: body,
98
+ };
99
+
100
+ context.response = response;
99
101
  },
100
102
  head: async (url) => {
101
103
  const URL = await selector(url);
@@ -103,20 +105,22 @@ const api = {
103
105
 
104
106
  const res = await context.request.head(resolvedURL);
105
107
 
108
+ const header = await res.headers();
109
+ let body;
106
110
  try {
107
- const header = await res.headers();
111
+ body = await res.json();
112
+ } catch (e) {
113
+ body = await res.text();
114
+ }
108
115
 
109
- const response = {
110
- url: res.url(),
111
- response: res,
112
- responseHeaders: header,
113
- responseBody: body,
114
- };
116
+ const response = {
117
+ url: res.url(),
118
+ response: res,
119
+ responseHeaders: header,
120
+ responseBody: body,
121
+ };
115
122
 
116
- context.response = response;
117
- } catch (error) {
118
- throw new Error(`Error processing response: ${error.message}`);
119
- }
123
+ context.response = response;
120
124
  },
121
125
  post: async (url, payload, bodyType) => {
122
126
  const URL = await selector(url);
@@ -148,22 +152,23 @@ const api = {
148
152
 
149
153
  const res = await context.request.post(resolvedURL, requestBody);
150
154
 
155
+ const header = await res.headers();
156
+ let body;
151
157
  try {
152
- const header = await res.headers();
153
- const body = await res.json();
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}`);
158
+ body = await res.json();
159
+ } catch (e) {
160
+ body = await res.text();
166
161
  }
162
+
163
+ const response = {
164
+ url: res.url(),
165
+ requestHeaders: payloadJSON.headers,
166
+ requestBody: payloadJSON.body,
167
+ response: res,
168
+ responseHeaders: header,
169
+ responseBody: body,
170
+ };
171
+ context.response = response;
167
172
  },
168
173
  put: async (url, payload, bodyType) => {
169
174
  const URL = await selector(url);
@@ -195,22 +200,23 @@ const api = {
195
200
 
196
201
  const res = await context.request.put(resolvedURL, requestBody);
197
202
 
203
+ const header = await res.headers();
204
+ let body;
198
205
  try {
199
- const header = await res.headers();
200
- const body = await res.json();
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}`);
206
+ body = await res.json();
207
+ } catch (e) {
208
+ body = await res.text();
213
209
  }
210
+
211
+ const response = {
212
+ url: res.url(),
213
+ requestHeaders: payloadJSON.headers,
214
+ requestBody: payloadJSON.body,
215
+ response: res,
216
+ responseHeaders: header,
217
+ responseBody: body,
218
+ };
219
+ context.response = response;
214
220
  },
215
221
  patch: async (url, payload, bodyType) => {
216
222
  const URL = await selector(url);
@@ -242,22 +248,23 @@ const api = {
242
248
 
243
249
  const res = await context.request.patch(resolvedURL, requestBody);
244
250
 
251
+ const header = await res.headers();
252
+ let body;
245
253
  try {
246
- const header = await res.headers();
247
- const body = await res.json();
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}`);
254
+ body = await res.json();
255
+ } catch (e) {
256
+ body = await res.text();
260
257
  }
258
+
259
+ const response = {
260
+ url: res.url(),
261
+ requestHeaders: payloadJSON.headers,
262
+ requestBody: payloadJSON.body,
263
+ response: res,
264
+ responseHeaders: header,
265
+ responseBody: body,
266
+ };
267
+ context.response = response;
261
268
  },
262
269
  delete: async (url, payload) => {
263
270
  const URL = await selector(url);
@@ -270,21 +277,23 @@ const api = {
270
277
  headers: payloadJSON.headers,
271
278
  });
272
279
 
280
+ const header = await res.headers();
281
+ let body;
273
282
  try {
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
- };
283
-
284
- context.response = response;
285
- } catch (error) {
286
- throw new Error(`Error processing response: ${error.message}`);
283
+ body = await res.json();
284
+ } catch (e) {
285
+ body = await res.text();
287
286
  }
287
+
288
+ const response = {
289
+ url: res.url(),
290
+ requestHeaders: payloadJSON.headers,
291
+ response: res,
292
+ responseHeaders: header,
293
+ responseBody: body,
294
+ };
295
+
296
+ context.response = response;
288
297
  },
289
298
  vars: () => {
290
299
  return context.vars;