@dev-blinq/cucumber_client 1.0.1318-dev → 1.0.1318-stage
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/bin/assets/bundled_scripts/recorder.js +108 -108
- package/bin/assets/preload/css_gen.js +10 -10
- package/bin/assets/preload/recorderv3.js +3 -1
- package/bin/assets/preload/toolbar.js +27 -29
- package/bin/assets/preload/unique_locators.js +1 -1
- package/bin/assets/preload/yaml.js +288 -275
- package/bin/assets/scripts/aria_snapshot.js +223 -220
- package/bin/assets/scripts/dom_attr.js +329 -329
- package/bin/assets/scripts/dom_parent.js +169 -174
- package/bin/assets/scripts/event_utils.js +94 -94
- package/bin/assets/scripts/pw.js +2050 -1949
- package/bin/assets/scripts/recorder.js +5 -17
- package/bin/assets/scripts/snapshot_capturer.js +153 -146
- package/bin/assets/scripts/unique_locators.js +156 -48
- package/bin/assets/scripts/yaml.js +796 -783
- package/bin/assets/templates/_hooks_template.txt +41 -0
- package/bin/assets/templates/utils_template.txt +1 -44
- package/bin/client/apiTest/apiTest.js +6 -0
- package/bin/client/cli_helpers.js +11 -13
- package/bin/client/code_cleanup/utils.js +5 -1
- package/bin/client/code_gen/api_codegen.js +2 -2
- package/bin/client/code_gen/code_inversion.js +53 -4
- package/bin/client/code_gen/page_reflection.js +839 -906
- package/bin/client/code_gen/playwright_codeget.js +32 -17
- package/bin/client/cucumber/feature.js +89 -27
- package/bin/client/cucumber/feature_data.js +2 -2
- package/bin/client/cucumber/project_to_document.js +9 -3
- package/bin/client/cucumber/steps_definitions.js +90 -87
- package/bin/client/cucumber_selector.js +17 -1
- package/bin/client/local_agent.js +6 -5
- package/bin/client/parse_feature_file.js +23 -26
- package/bin/client/playground/projects/env.json +2 -2
- package/bin/client/project.js +186 -196
- package/bin/client/recorderv3/bvt_recorder.js +187 -76
- package/bin/client/recorderv3/implemented_steps.js +74 -16
- package/bin/client/recorderv3/index.js +68 -54
- package/bin/client/recorderv3/scriptTest.js +1 -1
- package/bin/client/recorderv3/services.js +4 -16
- package/bin/client/recorderv3/step_runner.js +313 -170
- package/bin/client/recorderv3/step_utils.js +516 -4
- package/bin/client/recorderv3/update_feature.js +32 -30
- package/bin/client/run_cucumber.js +5 -1
- package/bin/client/scenario_report.js +0 -5
- package/bin/client/test_scenario.js +0 -1
- package/bin/client/upload-service.js +2 -2
- package/bin/client/utils/socket_logger.js +132 -0
- package/bin/index.js +1 -0
- package/bin/logger.js +3 -2
- package/bin/min/consoleApi.min.cjs +2 -3
- package/bin/min/injectedScript.min.cjs +16 -16
- package/package.json +21 -12
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
1
|
+
import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import fs from "fs";
|
|
4
3
|
import { generatePageName } from "../code_gen/playwright_codeget.js";
|
|
5
4
|
import {
|
|
6
5
|
executeStep,
|
|
@@ -9,49 +8,75 @@ import {
|
|
|
9
8
|
getUtilsCodePage,
|
|
10
9
|
loadStepDefinitions,
|
|
11
10
|
saveRecording,
|
|
11
|
+
saveRoutes,
|
|
12
12
|
} from "./step_utils.js";
|
|
13
13
|
import { escapeString, getExamplesContent } from "./update_feature.js";
|
|
14
|
+
import fs from "fs";
|
|
14
15
|
import { locateDefinitionPath } from "../cucumber/steps_definitions.js";
|
|
16
|
+
import { tmpdir } from "os";
|
|
17
|
+
import socketLogger from "../utils/socket_logger.js";
|
|
15
18
|
|
|
16
|
-
// let copiedCodeToTemp = false;
|
|
17
|
-
async function withAbort(fn, signal) {
|
|
18
|
-
if (!signal) {
|
|
19
|
-
return await fn();
|
|
20
|
-
}
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
const abortHandler = () => reject(new Error("Aborted"));
|
|
23
|
-
signal.addEventListener("abort", abortHandler, { once: true });
|
|
24
|
-
|
|
25
|
-
fn()
|
|
26
|
-
.then(resolve)
|
|
27
|
-
.catch(reject)
|
|
28
|
-
.finally(() => {
|
|
29
|
-
signal.removeEventListener("abort", abortHandler);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
19
|
export class BVTStepRunner {
|
|
34
|
-
#currentStepController;
|
|
20
|
+
#currentStepController = null;
|
|
35
21
|
#port;
|
|
36
|
-
|
|
22
|
+
#lastAttemptedCmdId = null;
|
|
23
|
+
|
|
24
|
+
constructor({ projectDir, sendExecutionStatus, bvtContext }) {
|
|
37
25
|
this.projectDir = projectDir;
|
|
38
26
|
this.sendExecutionStatus = sendExecutionStatus;
|
|
27
|
+
this.bvtContext = bvtContext;
|
|
28
|
+
this.liveExecutionMap = new Map();
|
|
39
29
|
}
|
|
30
|
+
|
|
40
31
|
setRemoteDebugPort(port) {
|
|
41
32
|
this.#port = port;
|
|
42
33
|
}
|
|
34
|
+
|
|
35
|
+
// Abort the current cucumber step execution by signaling the wrapper
|
|
43
36
|
async abortExecution() {
|
|
37
|
+
if (this.bvtContext.web.pausedCmd) {
|
|
38
|
+
this.bvtContext.web.pausedCmd = null;
|
|
39
|
+
}
|
|
40
|
+
this.liveExecutionMap.clear();
|
|
44
41
|
if (this.#currentStepController) {
|
|
45
42
|
this.#currentStepController.abort();
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
45
|
|
|
46
|
+
async pauseExecution(cmdId) {
|
|
47
|
+
if (this.bvtContext.web) {
|
|
48
|
+
this.bvtContext.web.pausedCmd = {
|
|
49
|
+
id: cmdId,
|
|
50
|
+
...this.liveExecutionMap.get(cmdId),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async resumeExecution(cmdId) {
|
|
56
|
+
if (this.bvtContext.web.pausedCmd) {
|
|
57
|
+
const { resolve } = this.bvtContext.web.pausedCmd;
|
|
58
|
+
if (resolve) {
|
|
59
|
+
resolve();
|
|
60
|
+
}
|
|
61
|
+
this.bvtContext.web.pausedCmd = null;
|
|
62
|
+
} else {
|
|
63
|
+
socketLogger.warn(`bvtContext.web.pausedCmd is null`);
|
|
64
|
+
if (this.liveExecutionMap.has(cmdId)) {
|
|
65
|
+
const { resolve } = this.liveExecutionMap.get(cmdId);
|
|
66
|
+
if (resolve) {
|
|
67
|
+
resolve();
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
console.warn(`No paused command found for cmdId: ${cmdId}`);
|
|
71
|
+
socketLogger.error(`No paused command found for cmdId: ${cmdId}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
49
76
|
async copyCodetoTempFolder({ step, parametersMap, tempFolderPath }) {
|
|
50
|
-
// const tempFolderPath = path.join(this.projectDir, "__temp_features");
|
|
51
77
|
if (!fs.existsSync(tempFolderPath)) {
|
|
52
78
|
fs.mkdirSync(tempFolderPath);
|
|
53
79
|
}
|
|
54
|
-
//copy all files from "./features" "./temp" folder
|
|
55
80
|
if (fs.existsSync(tempFolderPath)) {
|
|
56
81
|
fs.rmSync(tempFolderPath, { recursive: true });
|
|
57
82
|
}
|
|
@@ -59,12 +84,10 @@ export class BVTStepRunner {
|
|
|
59
84
|
overwrite: true,
|
|
60
85
|
recursive: true,
|
|
61
86
|
});
|
|
62
|
-
// copiedCodeToTemp = true;
|
|
63
87
|
}
|
|
64
88
|
|
|
65
89
|
async writeTempFeatureFile({ step, parametersMap, tempFolderPath, tags }) {
|
|
66
90
|
const tFilePath = path.join(tempFolderPath, "__temp.feature");
|
|
67
|
-
// console.log(tFilePath);
|
|
68
91
|
let tFileContent = `# temp feature file
|
|
69
92
|
Feature: Temp feature
|
|
70
93
|
${tags ? tags.join(" ") : ""}
|
|
@@ -76,180 +99,300 @@ export class BVTStepRunner {
|
|
|
76
99
|
return tFilePath;
|
|
77
100
|
}
|
|
78
101
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
102
|
+
// Generate wrapper code that integrates AbortSignal into cucumber step definitions
|
|
103
|
+
generateWrapperCode() {
|
|
104
|
+
return `
|
|
105
|
+
import {setDefinitionFunctionWrapper} from "@dev-blinq/cucumber-js";
|
|
106
|
+
|
|
107
|
+
setDefinitionFunctionWrapper((fn) => {
|
|
108
|
+
return async function (...args) {
|
|
109
|
+
const signal = global.__BVT_STEP_ABORT_SIGNAL;
|
|
110
|
+
if (signal) {
|
|
111
|
+
signal.throwIfAborted?.();
|
|
112
|
+
const abortHandler = () => {
|
|
113
|
+
throw new Error("Aborted");
|
|
83
114
|
};
|
|
115
|
+
signal.addEventListener("abort", abortHandler, { once: true });
|
|
116
|
+
try {
|
|
117
|
+
return await fn.apply(this, args);
|
|
118
|
+
} finally {
|
|
119
|
+
signal.removeEventListener("abort", abortHandler);
|
|
120
|
+
}
|
|
84
121
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
122
|
+
return await fn.apply(this, args);
|
|
123
|
+
};
|
|
124
|
+
});
|
|
88
125
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
126
|
+
`;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Write the wrapper code to temp folder
|
|
130
|
+
async writeWrapperCode(tempFolderPath, abortSignal) {
|
|
131
|
+
// tempFolderPath/step_definitions/utils.mjs -> Make a file name that follows this file but always before the next file
|
|
132
|
+
let fileName = "utils" + Math.random().toString(36).substring(2, 7) + ".mjs";
|
|
133
|
+
while (existsSync(path.join(tempFolderPath, "step_definitions", fileName))) {
|
|
134
|
+
fileName = "utils" + Math.random().toString(36).substring(2, 7) + ".mjs";
|
|
135
|
+
}
|
|
136
|
+
const wrapperCode = this.generateWrapperCode();
|
|
137
|
+
|
|
138
|
+
// Ensure directory exists
|
|
139
|
+
const stepDefinitionFolderPath = path.join(tempFolderPath, "step_definitions");
|
|
140
|
+
if (!existsSync(stepDefinitionFolderPath)) {
|
|
141
|
+
mkdirSync(stepDefinitionFolderPath, { recursive: true });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
writeFileSync(path.join(stepDefinitionFolderPath, fileName), wrapperCode);
|
|
145
|
+
|
|
146
|
+
// Set the abort signal globally so the wrapper can access it
|
|
147
|
+
global.__BVT_STEP_ABORT_SIGNAL = abortSignal;
|
|
148
|
+
|
|
149
|
+
return path.join(stepDefinitionFolderPath, fileName);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Execute cucumber step - simplified without abort signal handling at this level
|
|
153
|
+
async executeStepWithAbort({ feature_file_path, scenario, tempFolderPath, stepText, config }, options) {
|
|
154
|
+
const { skipAfter = true, skipBefore = true } = options || {};
|
|
155
|
+
|
|
156
|
+
const environment = { ...process.env };
|
|
157
|
+
const { loadConfiguration, loadSupport, runCucumber } = await import("@dev-blinq/cucumber-js/api");
|
|
158
|
+
|
|
159
|
+
const { runConfiguration } = await loadConfiguration(
|
|
160
|
+
{
|
|
161
|
+
provided: {
|
|
162
|
+
name: [scenario],
|
|
163
|
+
paths: [feature_file_path],
|
|
164
|
+
import: [path.join(tempFolderPath, "step_definitions", "**", "*.mjs")],
|
|
99
165
|
},
|
|
100
|
-
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// console.log("found ", support.stepDefinitions.length, "step definitions");
|
|
106
|
-
// support.stepDefinitions.map((step) => {
|
|
107
|
-
// console.log("step", step.pattern);
|
|
108
|
-
// });
|
|
109
|
-
|
|
110
|
-
if (options.skipAfter) {
|
|
111
|
-
// ignore afterAll/after hooks
|
|
112
|
-
support.afterTestCaseHookDefinitions = [];
|
|
113
|
-
support.afterTestRunHookDefinitions = [];
|
|
114
|
-
}
|
|
166
|
+
},
|
|
167
|
+
{ cwd: process.cwd(), env: environment }
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const support = await loadSupport(runConfiguration, { cwd: process.cwd(), env: environment });
|
|
115
171
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
172
|
+
support.afterTestRunHookDefinitions = [];
|
|
173
|
+
if (skipAfter) {
|
|
174
|
+
support.afterTestCaseHookDefinitions = [];
|
|
175
|
+
}
|
|
176
|
+
if (skipBefore && !config.legacySyntax) {
|
|
177
|
+
support.beforeTestCaseHookDefinitions = support.beforeTestCaseHookDefinitions.filter((hook) => {
|
|
178
|
+
return hook.uri.endsWith("_hooks.mjs");
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
support.beforeTestRunHookDefinitions = [];
|
|
182
|
+
|
|
183
|
+
let errorMessage = null;
|
|
184
|
+
let info = null;
|
|
185
|
+
let errInfo = null;
|
|
186
|
+
|
|
187
|
+
const result = await runCucumber({ ...runConfiguration, support }, environment, (message) => {
|
|
188
|
+
if (message.testStepFinished) {
|
|
189
|
+
const { testStepFinished } = message;
|
|
190
|
+
const { testStepResult } = testStepFinished;
|
|
191
|
+
if (testStepResult.status === "FAILED" || testStepResult.status === "AMBIGUOUS") {
|
|
192
|
+
if (!errorMessage) {
|
|
193
|
+
errorMessage = testStepResult.message;
|
|
194
|
+
if (info) {
|
|
195
|
+
errInfo = info;
|
|
129
196
|
}
|
|
130
197
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
198
|
+
}
|
|
199
|
+
if (testStepResult.status === "UNDEFINED") {
|
|
200
|
+
if (!errorMessage) {
|
|
201
|
+
errorMessage = `step ${JSON.stringify(stepText)} is ${testStepResult.status}`;
|
|
202
|
+
if (info) {
|
|
203
|
+
errInfo = info;
|
|
137
204
|
}
|
|
138
205
|
}
|
|
139
206
|
}
|
|
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
|
-
}
|
|
207
|
+
}
|
|
208
|
+
if (message.attachment) {
|
|
209
|
+
const attachment = message.attachment;
|
|
210
|
+
if (attachment.mediaType === "application/json" && attachment.body) {
|
|
211
|
+
const body = JSON.parse(attachment.body);
|
|
212
|
+
info = body.info;
|
|
213
|
+
const result = body.result;
|
|
214
|
+
|
|
215
|
+
if (result.status === "PASSED") {
|
|
216
|
+
this.sendExecutionStatus({
|
|
217
|
+
type: "cmdExecutionSuccess",
|
|
218
|
+
cmdId: body.cmdId,
|
|
219
|
+
info,
|
|
220
|
+
selectedStrategy: info?.selectedStrategy,
|
|
221
|
+
});
|
|
222
|
+
} else {
|
|
223
|
+
this.sendExecutionStatus({
|
|
224
|
+
type: "cmdExecutionError",
|
|
225
|
+
cmdId: body.cmdId,
|
|
226
|
+
error: {
|
|
227
|
+
message: result.message,
|
|
228
|
+
info,
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
} else if (attachment.mediaType === "application/json+intercept-results" && attachment.body) {
|
|
233
|
+
const body = JSON.parse(attachment.body);
|
|
234
|
+
if (body) {
|
|
235
|
+
this.sendExecutionStatus({
|
|
236
|
+
type: "interceptResults",
|
|
237
|
+
interceptResults: body,
|
|
238
|
+
});
|
|
172
239
|
}
|
|
173
240
|
}
|
|
174
|
-
});
|
|
175
|
-
if (errorMesssage) {
|
|
176
|
-
const bvtError = new Error(errorMesssage);
|
|
177
|
-
Object.assign(bvtError, { info: errInfo });
|
|
178
|
-
throw bvtError;
|
|
179
241
|
}
|
|
242
|
+
});
|
|
180
243
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
} catch (error) {
|
|
186
|
-
console.error("Error running cucumber-js", error);
|
|
187
|
-
throw error;
|
|
244
|
+
if (errorMessage) {
|
|
245
|
+
const bvtError = new Error(errorMessage);
|
|
246
|
+
Object.assign(bvtError, { info: errInfo });
|
|
247
|
+
throw bvtError;
|
|
188
248
|
}
|
|
189
|
-
};
|
|
190
249
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (cucumberStep.parameters && Array.isArray(cucumberStep.parameters)) {
|
|
207
|
-
cucumberStep.parameters.forEach((param) => {
|
|
208
|
-
if (param.variableName) {
|
|
209
|
-
param.callValue = parametersMap[param.variableName];
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
}
|
|
250
|
+
return { result, info };
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
async runStep({ step, parametersMap, envPath, tags, config }, bvtContext, options) {
|
|
254
|
+
// Create a new AbortController for this specific step execution
|
|
255
|
+
this.#currentStepController = new AbortController();
|
|
256
|
+
const { signal } = this.#currentStepController;
|
|
257
|
+
|
|
258
|
+
try {
|
|
259
|
+
this.#lastAttemptedCmdId = null;
|
|
260
|
+
let cmdIDs = (step.commands || []).map((cmd) => cmd.cmdId ?? cmd.id);
|
|
261
|
+
bvtContext.web.pausedCmd = null;
|
|
262
|
+
|
|
263
|
+
// Clear the liveExecutionMap and set up new entries for this step
|
|
264
|
+
this.liveExecutionMap.clear();
|
|
213
265
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
266
|
+
for (const cmdId of cmdIDs) {
|
|
267
|
+
this.liveExecutionMap.set(cmdId, {
|
|
268
|
+
resolve: () => {},
|
|
269
|
+
reject: () => {},
|
|
270
|
+
});
|
|
219
271
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
272
|
+
|
|
273
|
+
if (bvtContext.web) {
|
|
274
|
+
bvtContext.web.getCmdId = () => {
|
|
275
|
+
if (cmdIDs.length === 0) {
|
|
276
|
+
cmdIDs = (step.commands || []).map((cmd) => cmd.cmdId ?? cmd.id);
|
|
277
|
+
}
|
|
278
|
+
const cId = cmdIDs.shift();
|
|
279
|
+
this.sendExecutionStatus({
|
|
280
|
+
type: "cmdExecutionStart",
|
|
281
|
+
cmdId: cId,
|
|
282
|
+
});
|
|
283
|
+
this.#lastAttemptedCmdId = cId;
|
|
284
|
+
return cId;
|
|
285
|
+
};
|
|
227
286
|
}
|
|
228
|
-
|
|
229
|
-
|
|
287
|
+
|
|
288
|
+
const __temp_features_FolderName = "__temp_features" + Math.random().toString(36).substring(2, 7);
|
|
289
|
+
const tempFolderPath = path.join(this.projectDir, __temp_features_FolderName);
|
|
290
|
+
process.env.tempFeaturesFolderPath = __temp_features_FolderName;
|
|
291
|
+
process.env.TESTCASE_REPORT_FOLDER_PATH = tempFolderPath;
|
|
292
|
+
|
|
293
|
+
await this.copyCodetoTempFolder({ step, parametersMap, tempFolderPath });
|
|
294
|
+
|
|
295
|
+
// Write abort wrapper code with this step's signal
|
|
296
|
+
await this.writeWrapperCode(tempFolderPath, signal);
|
|
297
|
+
|
|
298
|
+
let stepsDefinitions = loadStepDefinitions(this.projectDir, false, true);
|
|
299
|
+
const cucumberStep = getCucumberStep({ step });
|
|
300
|
+
|
|
301
|
+
if (cucumberStep.parameters && Array.isArray(cucumberStep.parameters)) {
|
|
302
|
+
cucumberStep.parameters.forEach((param) => {
|
|
303
|
+
if (param.variableName) {
|
|
304
|
+
param.callValue = parametersMap[param.variableName];
|
|
305
|
+
}
|
|
306
|
+
});
|
|
230
307
|
}
|
|
231
|
-
}
|
|
232
|
-
const feature_file_path = await this.writeTempFeatureFile({ step, parametersMap, tempFolderPath, tags });
|
|
233
|
-
// console.log({ feature_file_path, step_text: step.text });
|
|
234
308
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
309
|
+
if (!step.isImplemented && step.commands.length > 0) {
|
|
310
|
+
const pageName = generatePageName(step.startFrame?.url ?? "default");
|
|
311
|
+
const stepDefinitionFolderPath = path.join(tempFolderPath, "step_definitions");
|
|
312
|
+
if (!existsSync(stepDefinitionFolderPath)) {
|
|
313
|
+
mkdirSync(stepDefinitionFolderPath, { recursive: true });
|
|
314
|
+
}
|
|
315
|
+
const stepDefsFilePath = locateDefinitionPath(tempFolderPath, pageName);
|
|
316
|
+
let codePage = getCodePage(stepDefsFilePath);
|
|
317
|
+
codePage = await saveRecording({
|
|
318
|
+
step,
|
|
319
|
+
cucumberStep,
|
|
320
|
+
codePage,
|
|
321
|
+
projectDir: this.projectDir,
|
|
322
|
+
stepsDefinitions,
|
|
323
|
+
parametersMap,
|
|
324
|
+
});
|
|
325
|
+
if (codePage) {
|
|
326
|
+
await codePage.save(stepDefsFilePath);
|
|
327
|
+
}
|
|
328
|
+
if (!codePage) {
|
|
329
|
+
codePage = getUtilsCodePage(this.projectDir);
|
|
330
|
+
}
|
|
331
|
+
} else {
|
|
332
|
+
let routesPath = path.join(tmpdir(), `blinq_temp_routes`);
|
|
333
|
+
if (process.env.TEMP_RUN === "true") {
|
|
334
|
+
if (existsSync(routesPath)) {
|
|
335
|
+
rmSync(routesPath, { recursive: true });
|
|
336
|
+
}
|
|
337
|
+
mkdirSync(routesPath, { recursive: true });
|
|
338
|
+
saveRoutes({ step, folderPath: routesPath });
|
|
339
|
+
} else {
|
|
340
|
+
if (existsSync(routesPath)) {
|
|
341
|
+
try {
|
|
342
|
+
rmSync(routesPath, { recursive: true });
|
|
343
|
+
} catch (error) {
|
|
344
|
+
console.error("Error removing temp_routes folder", error);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
routesPath = path.join(this.projectDir, "data", "routes");
|
|
348
|
+
if (!existsSync(routesPath)) {
|
|
349
|
+
mkdirSync(routesPath, { recursive: true });
|
|
350
|
+
}
|
|
351
|
+
saveRoutes({ step, folderPath: routesPath });
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const feature_file_path = await this.writeTempFeatureFile({
|
|
356
|
+
step,
|
|
357
|
+
parametersMap,
|
|
358
|
+
tempFolderPath,
|
|
359
|
+
tags,
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
// Execute the cucumber step - if wrapper throws "Aborted", it will propagate up
|
|
363
|
+
const { result, info } = await this.executeStepWithAbort(
|
|
239
364
|
{
|
|
240
365
|
feature_file_path,
|
|
241
366
|
tempFolderPath,
|
|
242
367
|
stepText: step.text,
|
|
243
368
|
scenario: "Temp Scenario",
|
|
369
|
+
config,
|
|
244
370
|
},
|
|
245
371
|
options
|
|
246
372
|
);
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
373
|
+
|
|
374
|
+
return { result, info };
|
|
375
|
+
} catch (error) {
|
|
376
|
+
if (error.message && error.message.includes("Aborted")) {
|
|
377
|
+
throw new Error("Aborted");
|
|
378
|
+
} else throw error;
|
|
379
|
+
} finally {
|
|
380
|
+
// Clean up this step's controller and global reference
|
|
381
|
+
this.#currentStepController = null;
|
|
382
|
+
global.__BVT_STEP_ABORT_SIGNAL = null;
|
|
383
|
+
|
|
384
|
+
try {
|
|
385
|
+
// Clean up temp folder
|
|
386
|
+
const __temp_features_FolderName = process.env.tempFeaturesFolderPath;
|
|
387
|
+
if (__temp_features_FolderName) {
|
|
388
|
+
const tempFolderPath = path.join(this.projectDir, __temp_features_FolderName);
|
|
389
|
+
if (fs.existsSync(tempFolderPath)) {
|
|
390
|
+
fs.rmSync(tempFolderPath, { recursive: true });
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
} catch (error) {
|
|
394
|
+
console.error("Error cleaning up temp folder", error);
|
|
251
395
|
}
|
|
252
|
-
}
|
|
253
|
-
return { result, info };
|
|
396
|
+
}
|
|
254
397
|
}
|
|
255
398
|
}
|