artes 1.0.72 → 1.0.74
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
|
+
};
|
|
@@ -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
|
@@ -3,7 +3,7 @@ const {
|
|
|
3
3
|
Before,
|
|
4
4
|
After,
|
|
5
5
|
Status,
|
|
6
|
-
setDefaultTimeout,
|
|
6
|
+
setDefaultTimeout, AfterStep
|
|
7
7
|
} = require("@cucumber/cucumber");
|
|
8
8
|
const { invokeBrowser } = require("../helper/contextManager/browserManager");
|
|
9
9
|
const { invokeRequest } = require("../helper/contextManager/requestManager");
|
|
@@ -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,34 +22,55 @@ 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;
|
|
33
|
+
|
|
34
|
+
await context.page.setDefaultTimeout(cucumberConfig.default.timeout * 1000);
|
|
36
35
|
|
|
37
|
-
await
|
|
36
|
+
await context.browserContext.tracing.start({
|
|
38
37
|
sources: true,
|
|
39
38
|
screenshots: true,
|
|
40
39
|
snapshots: true,
|
|
41
40
|
});
|
|
42
41
|
});
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
AfterStep(async function ({pickleStep}) {
|
|
44
|
+
const stepText = pickleStep.text;
|
|
45
|
+
|
|
46
|
+
const methods = ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE'];
|
|
46
47
|
|
|
48
|
+
if( methods.some(method => stepText.includes(method))){
|
|
49
|
+
if (context.response) {
|
|
50
|
+
for (const [key, value] of Object.entries(context.response)) {
|
|
51
|
+
let text = `${key}:\n`;
|
|
52
|
+
|
|
53
|
+
if (typeof value === 'object') {
|
|
54
|
+
text += JSON.stringify(value, null, 2);
|
|
55
|
+
} else {
|
|
56
|
+
text += value;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
await this.attach(text, "text/plain");
|
|
60
|
+
}
|
|
61
|
+
}}
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
After(async function ({ pickle, result }) {
|
|
47
65
|
if (result?.status != Status.PASSED) {
|
|
48
|
-
img = await context.page.screenshot({
|
|
66
|
+
let img = await context.page.screenshot({
|
|
49
67
|
path: `./test-results/visualReport/${pickle.name}/${pickle.name}.png`,
|
|
50
68
|
type: "png",
|
|
51
69
|
});
|
|
52
70
|
await this.attach(img, "image/png");
|
|
53
71
|
}
|
|
54
72
|
|
|
55
|
-
await
|
|
73
|
+
await context.browserContext.tracing.stop({
|
|
56
74
|
path: path.join(moduleConfig.projectPath, "./trace.zip"),
|
|
57
75
|
});
|
|
58
76
|
|
|
@@ -70,13 +88,22 @@ After(async function ({ pickle, result }) {
|
|
|
70
88
|
}
|
|
71
89
|
}
|
|
72
90
|
|
|
73
|
-
await context.page
|
|
74
|
-
|
|
75
|
-
await context.
|
|
76
|
-
|
|
77
|
-
|
|
91
|
+
await context.page?.close();
|
|
92
|
+
|
|
93
|
+
await context.browserContext?.close();
|
|
94
|
+
|
|
95
|
+
await context.browser?.close();
|
|
96
|
+
|
|
97
|
+
await context.request?.dispose();
|
|
98
|
+
|
|
99
|
+
if (result?.status != Status.PASSED && context.page.video()) {
|
|
78
100
|
const videoPath = await context.page.video().path();
|
|
79
|
-
|
|
80
|
-
|
|
101
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
102
|
+
|
|
103
|
+
if (fs.existsSync(videoPath)) {
|
|
104
|
+
const webmBuffer = await fs.readFileSync(videoPath);
|
|
105
|
+
await this.attach(webmBuffer, "video/webm");
|
|
106
|
+
}
|
|
81
107
|
}
|
|
82
|
-
|
|
108
|
+
|
|
109
|
+
});
|