artes 1.0.71 → 1.0.73
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
|
@@ -58,9 +58,13 @@ const invokeBrowser = async () => {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const context = await browser.newContext(browserContextOptions);
|
|
61
|
-
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
browser: browser,
|
|
64
|
+
context: context
|
|
65
|
+
};
|
|
62
66
|
};
|
|
63
67
|
|
|
64
68
|
module.exports = {
|
|
65
69
|
invokeBrowser,
|
|
66
|
-
};
|
|
70
|
+
};
|
|
@@ -87,10 +87,14 @@ async function requestMaker(headers, data, requestDataType) {
|
|
|
87
87
|
return request;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
async function responseMaker(request, response) {
|
|
90
|
+
async function responseMaker(request, response, duration) {
|
|
91
91
|
const responseObject = {};
|
|
92
92
|
|
|
93
|
-
response && Object.assign(responseObject, {
|
|
93
|
+
response && Object.assign(responseObject, {
|
|
94
|
+
"Response Params": `URL: ${response.url()}
|
|
95
|
+
Response Status: ${await response.status()}
|
|
96
|
+
Response Time: ${Math.round(duration)} ms`
|
|
97
|
+
});
|
|
94
98
|
|
|
95
99
|
request?.headers &&
|
|
96
100
|
Object.assign(responseObject, { "Request Headers": await request.headers });
|
|
@@ -113,6 +117,8 @@ async function responseMaker(request, response) {
|
|
|
113
117
|
}
|
|
114
118
|
}
|
|
115
119
|
|
|
120
|
+
Object.assign(responseObject, { "Response Time": `${Math.round(duration)} ms`});
|
|
121
|
+
|
|
116
122
|
return responseObject;
|
|
117
123
|
}
|
|
118
124
|
|
|
@@ -126,9 +132,13 @@ const api = {
|
|
|
126
132
|
|
|
127
133
|
const req = await requestMaker(payloadJSON?.headers || {});
|
|
128
134
|
|
|
135
|
+
const requestStarts = performance.now();
|
|
136
|
+
|
|
129
137
|
const res = await context.request.get(resolvedURL, req);
|
|
130
138
|
|
|
131
|
-
const
|
|
139
|
+
const duration = performance.now() - requestStarts;
|
|
140
|
+
|
|
141
|
+
const response = responseMaker(payloadJSON, res, duration);
|
|
132
142
|
|
|
133
143
|
context.response = await response;
|
|
134
144
|
},
|
|
@@ -136,9 +146,13 @@ const api = {
|
|
|
136
146
|
const URL = await selector(url);
|
|
137
147
|
const resolvedURL = await resolveVariable(URL);
|
|
138
148
|
|
|
149
|
+
const requestStarts = performance.now();
|
|
150
|
+
|
|
139
151
|
const res = await context.request.head(resolvedURL);
|
|
140
152
|
|
|
141
|
-
const
|
|
153
|
+
const duration = performance.now() - requestStarts;
|
|
154
|
+
|
|
155
|
+
const response = responseMaker(payloadJSON, res, duration);
|
|
142
156
|
|
|
143
157
|
context.response = await response;
|
|
144
158
|
},
|
|
@@ -172,9 +186,13 @@ const api = {
|
|
|
172
186
|
);
|
|
173
187
|
}
|
|
174
188
|
|
|
189
|
+
const requestStarts = performance.now();
|
|
190
|
+
|
|
175
191
|
const res = await context.request.post(resolvedURL, req);
|
|
176
192
|
|
|
177
|
-
const
|
|
193
|
+
const duration = performance.now() - requestStarts;
|
|
194
|
+
|
|
195
|
+
const response = await responseMaker(payloadJSON, res, duration);
|
|
178
196
|
|
|
179
197
|
context.response = response;
|
|
180
198
|
},
|
|
@@ -209,9 +227,13 @@ const api = {
|
|
|
209
227
|
);
|
|
210
228
|
}
|
|
211
229
|
|
|
230
|
+
const requestStarts = performance.now();
|
|
231
|
+
|
|
212
232
|
const res = await context.request.put(resolvedURL, req);
|
|
213
233
|
|
|
214
|
-
const
|
|
234
|
+
const duration = performance.now() - requestStarts;
|
|
235
|
+
|
|
236
|
+
const response = await responseMaker(payloadJSON, res, duration);
|
|
215
237
|
|
|
216
238
|
context.response = response;
|
|
217
239
|
},
|
|
@@ -246,9 +268,13 @@ const api = {
|
|
|
246
268
|
);
|
|
247
269
|
}
|
|
248
270
|
|
|
271
|
+
const requestStarts = performance.now();
|
|
272
|
+
|
|
249
273
|
const res = await context.request.patch(resolvedURL, req);
|
|
250
274
|
|
|
251
|
-
const
|
|
275
|
+
const duration = performance.now() - requestStarts;
|
|
276
|
+
|
|
277
|
+
const response = await responseMaker(payloadJSON, res, duration);
|
|
252
278
|
|
|
253
279
|
context.response = response;
|
|
254
280
|
},
|
|
@@ -261,9 +287,13 @@ const api = {
|
|
|
261
287
|
|
|
262
288
|
const req = await requestMaker(payloadJSON?.headers || {});
|
|
263
289
|
|
|
290
|
+
const requestStarts = performance.now();
|
|
291
|
+
|
|
264
292
|
const res = await context.request.delete(resolvedURL, req);
|
|
265
293
|
|
|
266
|
-
const
|
|
294
|
+
const duration = performance.now() - requestStarts;
|
|
295
|
+
|
|
296
|
+
const response = responseMaker(payloadJSON, res, duration);
|
|
267
297
|
|
|
268
298
|
context.response = await response;
|
|
269
299
|
},
|
|
@@ -12,10 +12,10 @@ const browser = {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
cookieData = Array.isArray(cookieData) ? cookieData : [cookieData];
|
|
15
|
-
await context.
|
|
15
|
+
await context.browserContext.addCookies(cookieData);
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
module.exports = {
|
|
20
20
|
browser,
|
|
21
|
-
};
|
|
21
|
+
};
|
package/src/hooks/hooks.js
CHANGED
|
@@ -14,9 +14,6 @@ const fs = require("fs");
|
|
|
14
14
|
const { moduleConfig } = require("artes/src/helper/imports/commons");
|
|
15
15
|
const path = require("path");
|
|
16
16
|
|
|
17
|
-
let browser;
|
|
18
|
-
let request;
|
|
19
|
-
|
|
20
17
|
setDefaultTimeout(cucumberConfig.default.timeout * 1000);
|
|
21
18
|
|
|
22
19
|
BeforeAll(async function () {
|
|
@@ -25,16 +22,18 @@ BeforeAll(async function () {
|
|
|
25
22
|
|
|
26
23
|
Before(async function () {
|
|
27
24
|
context.vars = {};
|
|
28
|
-
browser = await invokeBrowser();
|
|
29
|
-
request = await invokeRequest();
|
|
30
25
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
await context.page.setDefaultTimeout(cucumberConfig.default.timeout * 1000);
|
|
26
|
+
const { browser, context: browserContext } = await invokeBrowser();
|
|
27
|
+
const requestInstance = await invokeRequest();
|
|
34
28
|
|
|
35
|
-
context.
|
|
29
|
+
context.browser = browser;
|
|
30
|
+
context.browserContext = browserContext;
|
|
31
|
+
context.page = await browserContext.newPage();
|
|
32
|
+
context.request = requestInstance;
|
|
36
33
|
|
|
37
|
-
await
|
|
34
|
+
await context.page.setDefaultTimeout(cucumberConfig.default.timeout * 1000);
|
|
35
|
+
|
|
36
|
+
await context.browserContext.tracing.start({
|
|
38
37
|
sources: true,
|
|
39
38
|
screenshots: true,
|
|
40
39
|
snapshots: true,
|
|
@@ -42,36 +41,48 @@ Before(async function () {
|
|
|
42
41
|
});
|
|
43
42
|
|
|
44
43
|
After(async function ({ pickle, result }) {
|
|
45
|
-
let img;
|
|
46
|
-
|
|
47
44
|
if (result?.status != Status.PASSED) {
|
|
48
|
-
img = await context.page.screenshot({
|
|
45
|
+
let img = await context.page.screenshot({
|
|
49
46
|
path: `./test-results/visualReport/${pickle.name}/${pickle.name}.png`,
|
|
50
47
|
type: "png",
|
|
51
48
|
});
|
|
52
49
|
await this.attach(img, "image/png");
|
|
53
50
|
}
|
|
54
51
|
|
|
55
|
-
await
|
|
52
|
+
await context.browserContext.tracing.stop({
|
|
56
53
|
path: path.join(moduleConfig.projectPath, "./trace.zip"),
|
|
57
54
|
});
|
|
58
55
|
|
|
59
56
|
if (context.response) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
for (const [key, value] of Object.entries(context.response)) {
|
|
58
|
+
let text = `${key}:\n`;
|
|
59
|
+
|
|
60
|
+
if (typeof value === 'object') {
|
|
61
|
+
text += JSON.stringify(value, null, 2);
|
|
62
|
+
} else {
|
|
63
|
+
text += value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
await this.attach(text, "text/plain");
|
|
67
|
+
}
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
await context.page
|
|
69
|
-
|
|
70
|
-
await context.
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
await context.page?.close();
|
|
71
|
+
|
|
72
|
+
await context.browserContext?.close();
|
|
73
|
+
|
|
74
|
+
await context.browser?.close();
|
|
75
|
+
|
|
76
|
+
await context.request?.dispose();
|
|
77
|
+
|
|
78
|
+
if (result?.status != Status.PASSED && context.page.video()) {
|
|
73
79
|
const videoPath = await context.page.video().path();
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
81
|
+
|
|
82
|
+
if (fs.existsSync(videoPath)) {
|
|
83
|
+
const webmBuffer = await fs.readFileSync(videoPath);
|
|
84
|
+
await this.attach(webmBuffer, "video/webm");
|
|
85
|
+
}
|
|
76
86
|
}
|
|
77
|
-
|
|
87
|
+
|
|
88
|
+
});
|