artes 1.7.4 → 1.7.6
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 +781 -779
- package/assets/styles.css +4 -4
- package/cucumber.config.js +253 -253
- package/docs/ciExecutors.md +198 -198
- package/docs/emulationDevicesList.md +152 -152
- package/docs/functionDefinitions.md +2401 -2401
- package/docs/stepDefinitions.md +435 -433
- package/executer.js +266 -264
- package/index.js +50 -50
- package/package.json +56 -56
- package/src/helper/contextManager/browserManager.js +74 -74
- package/src/helper/contextManager/requestManager.js +23 -23
- package/src/helper/controller/elementController.js +210 -210
- package/src/helper/controller/findDuplicateTestNames.js +69 -69
- package/src/helper/controller/getEnvInfo.js +94 -94
- package/src/helper/controller/getExecutor.js +109 -109
- package/src/helper/controller/pomCollector.js +83 -83
- package/src/helper/controller/reportCustomizer.js +485 -485
- package/src/helper/controller/screenComparer.js +97 -108
- package/src/helper/controller/status-formatter.js +137 -137
- package/src/helper/controller/testCoverageCalculator.js +111 -111
- package/src/helper/executers/cleaner.js +23 -23
- package/src/helper/executers/exporter.js +19 -19
- package/src/helper/executers/helper.js +193 -191
- package/src/helper/executers/projectCreator.js +226 -222
- package/src/helper/executers/reportGenerator.js +91 -91
- package/src/helper/executers/testRunner.js +28 -28
- package/src/helper/executers/versionChecker.js +31 -31
- package/src/helper/imports/commons.js +65 -65
- package/src/helper/stepFunctions/APIActions.js +495 -495
- package/src/helper/stepFunctions/assertions.js +986 -986
- package/src/helper/stepFunctions/browserActions.js +87 -87
- package/src/helper/stepFunctions/elementInteractions.js +60 -60
- package/src/helper/stepFunctions/exporter.js +19 -19
- package/src/helper/stepFunctions/frameActions.js +72 -72
- package/src/helper/stepFunctions/keyboardActions.js +66 -66
- package/src/helper/stepFunctions/mouseActions.js +84 -84
- package/src/helper/stepFunctions/pageActions.js +43 -43
- package/src/hooks/context.js +15 -15
- package/src/hooks/hooks.js +287 -279
- package/src/stepDefinitions/API.steps.js +310 -310
- package/src/stepDefinitions/assertions.steps.js +1303 -1280
- package/src/stepDefinitions/browser.steps.js +74 -74
- package/src/stepDefinitions/frameActions.steps.js +76 -76
- package/src/stepDefinitions/keyboardActions.steps.js +264 -264
- package/src/stepDefinitions/mouseActions.steps.js +378 -378
- package/src/stepDefinitions/page.steps.js +71 -71
- package/src/stepDefinitions/random.steps.js +191 -191
package/src/hooks/hooks.js
CHANGED
|
@@ -1,279 +1,287 @@
|
|
|
1
|
-
const {
|
|
2
|
-
BeforeAll,
|
|
3
|
-
Before,
|
|
4
|
-
After,
|
|
5
|
-
Status,
|
|
6
|
-
setDefaultTimeout,
|
|
7
|
-
AfterStep,
|
|
8
|
-
BeforeStep,
|
|
9
|
-
AfterAll,
|
|
10
|
-
} = require("@cucumber/cucumber");
|
|
11
|
-
const { invokeBrowser } = require("../helper/contextManager/browserManager");
|
|
12
|
-
const { invokeRequest } = require("../helper/contextManager/requestManager");
|
|
13
|
-
const { pomCollector } = require("../helper/controller/pomCollector");
|
|
14
|
-
const cucumberConfig = require("../../cucumber.config");
|
|
15
|
-
const { context } = require("./context");
|
|
16
|
-
const fs = require("fs");
|
|
17
|
-
const path = require("path");
|
|
18
|
-
const { moduleConfig, saveVar } = require("artes/src/helper/imports/commons");
|
|
19
|
-
require("allure-cucumberjs");
|
|
20
|
-
const allure = require("allure-js-commons");
|
|
21
|
-
const ffprobe = require("ffprobe-static");
|
|
22
|
-
const ffmpegPath = require("ffmpeg-static");
|
|
23
|
-
const { execSync } = require("child_process");
|
|
24
|
-
const { attachAiBugReport } = require("artes/src/helper/controller/aiBugReporter");
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const HTTP_METHODS = ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"];
|
|
28
|
-
|
|
29
|
-
/* ------------------- Helpers ------------------- */
|
|
30
|
-
|
|
31
|
-
setDefaultTimeout(cucumberConfig.default.timeout);
|
|
32
|
-
|
|
33
|
-
async function attachResponse(attachFn) {
|
|
34
|
-
if (!context.response) return;
|
|
35
|
-
|
|
36
|
-
for (const [key, value] of Object.entries(context.response)) {
|
|
37
|
-
const text =
|
|
38
|
-
typeof value === "object"
|
|
39
|
-
? `${key}:\n${JSON.stringify(value, null, 2)}`
|
|
40
|
-
: `${key}:\n${value}`;
|
|
41
|
-
|
|
42
|
-
await attachFn(key, text, "application/json");
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const projectHooksPath = path.resolve(
|
|
47
|
-
moduleConfig.projectPath,
|
|
48
|
-
"tests/steps/hooks.js",
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
let projectHooks = {};
|
|
52
|
-
|
|
53
|
-
if (fs.existsSync(projectHooksPath)) {
|
|
54
|
-
try {
|
|
55
|
-
projectHooks = require(projectHooksPath);
|
|
56
|
-
} catch (err) {
|
|
57
|
-
console.warn("⚠️ Failed to load project hooks.js:", err.message);
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
projectHooks = {};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/* ------------------- Hooks ------------------- */
|
|
64
|
-
|
|
65
|
-
BeforeAll(async () => {
|
|
66
|
-
if (typeof projectHooks.BeforeAll === "function") {
|
|
67
|
-
await projectHooks.BeforeAll();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
pomCollector();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
Before(async function ({ pickle }) {
|
|
74
|
-
context.vars = {};
|
|
75
|
-
|
|
76
|
-
const vars = await cucumberConfig.variables;
|
|
77
|
-
|
|
78
|
-
if (vars && typeof vars === "object") {
|
|
79
|
-
for (let [key, value] of Object.entries(vars)) {
|
|
80
|
-
saveVar(value, key);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const envFilePath = path.join(
|
|
85
|
-
moduleConfig.projectPath,
|
|
86
|
-
"tests",
|
|
87
|
-
"environment_variables",
|
|
88
|
-
`${cucumberConfig.env}.env.json`,
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
if (fs.existsSync(envFilePath)) {
|
|
92
|
-
let env_vars = fs.readFileSync(envFilePath, "utf-8");
|
|
93
|
-
try {
|
|
94
|
-
env_vars = JSON.parse(env_vars);
|
|
95
|
-
context.vars = { ...context.vars, ...env_vars };
|
|
96
|
-
} catch (err) {
|
|
97
|
-
console.error("Error parsing environment variables JSON:", err);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const { browser, context: browserContext } = await invokeBrowser();
|
|
102
|
-
const requestInstance = await invokeRequest();
|
|
103
|
-
|
|
104
|
-
context.browser = browser;
|
|
105
|
-
context.browserContext = browserContext;
|
|
106
|
-
context.page = await browserContext.newPage();
|
|
107
|
-
context.request = requestInstance;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
)
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
1
|
+
const {
|
|
2
|
+
BeforeAll,
|
|
3
|
+
Before,
|
|
4
|
+
After,
|
|
5
|
+
Status,
|
|
6
|
+
setDefaultTimeout,
|
|
7
|
+
AfterStep,
|
|
8
|
+
BeforeStep,
|
|
9
|
+
AfterAll,
|
|
10
|
+
} = require("@cucumber/cucumber");
|
|
11
|
+
const { invokeBrowser } = require("../helper/contextManager/browserManager");
|
|
12
|
+
const { invokeRequest } = require("../helper/contextManager/requestManager");
|
|
13
|
+
const { pomCollector } = require("../helper/controller/pomCollector");
|
|
14
|
+
const cucumberConfig = require("../../cucumber.config");
|
|
15
|
+
const { context } = require("./context");
|
|
16
|
+
const fs = require("fs");
|
|
17
|
+
const path = require("path");
|
|
18
|
+
const { moduleConfig, saveVar } = require("artes/src/helper/imports/commons");
|
|
19
|
+
require("allure-cucumberjs");
|
|
20
|
+
const allure = require("allure-js-commons");
|
|
21
|
+
const ffprobe = require("ffprobe-static");
|
|
22
|
+
const ffmpegPath = require("ffmpeg-static");
|
|
23
|
+
const { execSync } = require("child_process");
|
|
24
|
+
const { attachAiBugReport } = require("artes/src/helper/controller/aiBugReporter");
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const HTTP_METHODS = ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"];
|
|
28
|
+
|
|
29
|
+
/* ------------------- Helpers ------------------- */
|
|
30
|
+
|
|
31
|
+
setDefaultTimeout(cucumberConfig.default.timeout);
|
|
32
|
+
|
|
33
|
+
async function attachResponse(attachFn) {
|
|
34
|
+
if (!context.response) return;
|
|
35
|
+
|
|
36
|
+
for (const [key, value] of Object.entries(context.response)) {
|
|
37
|
+
const text =
|
|
38
|
+
typeof value === "object"
|
|
39
|
+
? `${key}:\n${JSON.stringify(value, null, 2)}`
|
|
40
|
+
: `${key}:\n${value}`;
|
|
41
|
+
|
|
42
|
+
await attachFn(key, text, "application/json");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const projectHooksPath = path.resolve(
|
|
47
|
+
moduleConfig.projectPath,
|
|
48
|
+
"tests/steps/hooks.js",
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
let projectHooks = {};
|
|
52
|
+
|
|
53
|
+
if (fs.existsSync(projectHooksPath)) {
|
|
54
|
+
try {
|
|
55
|
+
projectHooks = require(projectHooksPath);
|
|
56
|
+
} catch (err) {
|
|
57
|
+
console.warn("⚠️ Failed to load project hooks.js:", err.message);
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
projectHooks = {};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* ------------------- Hooks ------------------- */
|
|
64
|
+
|
|
65
|
+
BeforeAll(async () => {
|
|
66
|
+
if (typeof projectHooks.BeforeAll === "function") {
|
|
67
|
+
await projectHooks.BeforeAll();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
pomCollector();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
Before(async function ({ pickle }) {
|
|
74
|
+
context.vars = {};
|
|
75
|
+
|
|
76
|
+
const vars = await cucumberConfig.variables;
|
|
77
|
+
|
|
78
|
+
if (vars && typeof vars === "object") {
|
|
79
|
+
for (let [key, value] of Object.entries(vars)) {
|
|
80
|
+
saveVar(value, key);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const envFilePath = path.join(
|
|
85
|
+
moduleConfig.projectPath,
|
|
86
|
+
"tests",
|
|
87
|
+
"environment_variables",
|
|
88
|
+
`${cucumberConfig.env}.env.json`,
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
if (fs.existsSync(envFilePath)) {
|
|
92
|
+
let env_vars = fs.readFileSync(envFilePath, "utf-8");
|
|
93
|
+
try {
|
|
94
|
+
env_vars = JSON.parse(env_vars);
|
|
95
|
+
context.vars = { ...context.vars, ...env_vars };
|
|
96
|
+
} catch (err) {
|
|
97
|
+
console.error("Error parsing environment variables JSON:", err);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const { browser, context: browserContext } = await invokeBrowser();
|
|
102
|
+
const requestInstance = await invokeRequest();
|
|
103
|
+
|
|
104
|
+
context.browser = browser;
|
|
105
|
+
context.browserContext = browserContext;
|
|
106
|
+
context.page = await browserContext.newPage();
|
|
107
|
+
context.request = requestInstance;
|
|
108
|
+
context.pickle = pickle;
|
|
109
|
+
|
|
110
|
+
const dimensions = await context.page.evaluate(() => {
|
|
111
|
+
return {
|
|
112
|
+
width: window.innerWidth,
|
|
113
|
+
height: window.innerHeight,
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
fs.writeFileSync(
|
|
118
|
+
path.join(moduleConfig.modulePath, "browser-info.json"),
|
|
119
|
+
JSON.stringify({
|
|
120
|
+
BROWSER_WIDTH: dimensions.width,
|
|
121
|
+
BROWSER_HEIGHT: dimensions.height,
|
|
122
|
+
BROWSER_VERSION: browser.version(),
|
|
123
|
+
}),
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
await context.page.setDefaultTimeout(cucumberConfig.default.timeout);
|
|
127
|
+
|
|
128
|
+
if (cucumberConfig.default.reportWithTrace || cucumberConfig.default.trace) {
|
|
129
|
+
await browserContext.tracing.start({
|
|
130
|
+
title: pickle.name,
|
|
131
|
+
sources: true,
|
|
132
|
+
screenshots: true,
|
|
133
|
+
snapshots: true,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (typeof projectHooks.Before === "function") {
|
|
138
|
+
await projectHooks.Before();
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
BeforeStep(async ({ pickleStep }) => {
|
|
143
|
+
context.step = pickleStep;
|
|
144
|
+
|
|
145
|
+
if (HTTP_METHODS.some((method) => pickleStep.text.includes(method))) {
|
|
146
|
+
context.response = {};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (typeof projectHooks.BeforeStep === "function") {
|
|
150
|
+
await projectHooks.BeforeStep();
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
AfterStep(async function ({ pickleStep }) {
|
|
155
|
+
context.step = pickleStep;
|
|
156
|
+
|
|
157
|
+
if (typeof projectHooks.AfterStep === "function") {
|
|
158
|
+
await projectHooks.AfterStep();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (HTTP_METHODS.some((method) => pickleStep.text.includes(method))) {
|
|
162
|
+
await attachResponse(allure.attachment);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
After(async function ({ result, pickle }) {
|
|
167
|
+
context.pickle = pickle
|
|
168
|
+
context.pickleResult = result
|
|
169
|
+
|
|
170
|
+
const shouldReport =
|
|
171
|
+
cucumberConfig.default.successReport || result?.status !== Status.PASSED;
|
|
172
|
+
|
|
173
|
+
await attachResponse(allure.attachment);
|
|
174
|
+
|
|
175
|
+
if (shouldReport && cucumberConfig.ai.ai === "true") {
|
|
176
|
+
await attachAiBugReport({
|
|
177
|
+
result,
|
|
178
|
+
pickle,
|
|
179
|
+
response: context.response,
|
|
180
|
+
language: cucumberConfig.ai.language,
|
|
181
|
+
url: cucumberConfig.ai.url,
|
|
182
|
+
aiModel: cucumberConfig.ai.model,
|
|
183
|
+
aiKey: cucumberConfig.ai.key,
|
|
184
|
+
maxReports: cucumberConfig.ai.maxReports,
|
|
185
|
+
maxTokens: cucumberConfig.ai.maxTokens
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
if (typeof projectHooks.After === "function") {
|
|
191
|
+
await projectHooks.After();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
context.response = await {};
|
|
196
|
+
|
|
197
|
+
Object.keys(context.vars).length > 0 &&
|
|
198
|
+
allure.attachment(
|
|
199
|
+
"Variables",
|
|
200
|
+
JSON.stringify(context.vars, null, 2),
|
|
201
|
+
"application/json",
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
if (shouldReport & (context.page.url() !== "about:blank")) {
|
|
206
|
+
const screenshotBuffer = await context.page.screenshot({ type: "png" });
|
|
207
|
+
|
|
208
|
+
await allure.attachment("Screenshot", screenshotBuffer, "image/png");
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (cucumberConfig.default.reportWithTrace || cucumberConfig.default.trace) {
|
|
212
|
+
var tracePath = path.join(
|
|
213
|
+
moduleConfig.projectPath,
|
|
214
|
+
`./traces/${pickle.name.replaceAll(" ", "_")}-${pickle.id}.zip`,
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (
|
|
219
|
+
(cucumberConfig.default.reportWithTrace || cucumberConfig.default.trace) &&
|
|
220
|
+
shouldReport &&
|
|
221
|
+
context.page.url() !== "about:blank"
|
|
222
|
+
) {
|
|
223
|
+
await context.browserContext.tracing.stop({
|
|
224
|
+
path: tracePath,
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
if (cucumberConfig.default.reportWithTrace) {
|
|
228
|
+
await allure.attachTrace("Trace", tracePath);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
await context.page?.close();
|
|
233
|
+
await context.browserContext?.close();
|
|
234
|
+
await context.browser?.close();
|
|
235
|
+
await context.request?.dispose();
|
|
236
|
+
|
|
237
|
+
if (
|
|
238
|
+
shouldReport &&
|
|
239
|
+
context.page.video &&
|
|
240
|
+
context.page.url() !== "about:blank"
|
|
241
|
+
) {
|
|
242
|
+
const video = context.page.video();
|
|
243
|
+
|
|
244
|
+
if (video) {
|
|
245
|
+
const videoPath = await video.path();
|
|
246
|
+
|
|
247
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
248
|
+
|
|
249
|
+
if (fs.existsSync(videoPath)) {
|
|
250
|
+
const trimmedPath = videoPath.replace(".webm", "-trimmed.webm");
|
|
251
|
+
|
|
252
|
+
const isTimeoutError = result.message?.includes(
|
|
253
|
+
"Error: function timed out, ensure the promise resolves within",
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
if (isTimeoutError) {
|
|
257
|
+
const duration = parseFloat(
|
|
258
|
+
execSync(
|
|
259
|
+
`"${ffprobe.path}" -v error -show_entries format=duration -of csv=p=0 "${videoPath}"`,
|
|
260
|
+
)
|
|
261
|
+
.toString()
|
|
262
|
+
.trim(),
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
const timeoutSeconds = cucumberConfig.default.timeout / 1000;
|
|
266
|
+
const newDuration = Math.max(duration - timeoutSeconds + 3, 1);
|
|
267
|
+
|
|
268
|
+
execSync(
|
|
269
|
+
`"${ffmpegPath}" -loglevel quiet -i "${videoPath}" -t ${newDuration} -c copy "${trimmedPath}" -y`,
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
const webmBuffer = fs.readFileSync(trimmedPath);
|
|
273
|
+
await allure.attachment("Screenrecord", webmBuffer, "video/webm");
|
|
274
|
+
} else {
|
|
275
|
+
const webmBuffer = fs.readFileSync(videoPath);
|
|
276
|
+
await allure.attachment("Screenrecord", webmBuffer, "video/webm");
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
AfterAll(async () => {
|
|
284
|
+
if (typeof projectHooks.AfterAll === "function") {
|
|
285
|
+
await projectHooks.AfterAll();
|
|
286
|
+
}
|
|
287
|
+
});
|