@dev-blinq/cucumber_client 1.0.1196-dev → 1.0.1198-dev
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.
|
@@ -289,7 +289,7 @@ class Feature {
|
|
|
289
289
|
}
|
|
290
290
|
return scenarios;
|
|
291
291
|
}
|
|
292
|
-
generateStracture(stepsDefinitions, fileName, scenarioName = null) {
|
|
292
|
+
generateStracture(stepsDefinitions, fileName, scenarioName = null, errorsInParsing = [], parseFailedFiles = false) {
|
|
293
293
|
const document = {};
|
|
294
294
|
document.featureName = this.feature.name;
|
|
295
295
|
document.fileName = fileName;
|
|
@@ -311,6 +311,28 @@ class Feature {
|
|
|
311
311
|
stepInfo.template = step.getTemplate();
|
|
312
312
|
scenarioInfo.steps.push(stepInfo);
|
|
313
313
|
const stepDef = stepsDefinitions.findMatchingStep(stepInfo.template);
|
|
314
|
+
if (!stepDef && parseFailedFiles) {
|
|
315
|
+
//Check if the stepName exists in one of the failedToParseFiles
|
|
316
|
+
try {
|
|
317
|
+
const stepName = stepsDefinitions._stepNameToTemplate(stepInfo.template);
|
|
318
|
+
if (errorsInParsing && errorsInParsing.length > 0) {
|
|
319
|
+
for (let k = 0; k < errorsInParsing.length; k++) {
|
|
320
|
+
const failedFile = errorsInParsing[k].file;
|
|
321
|
+
//Read File content, and check if the stepName exists in the file
|
|
322
|
+
const fileContent = fs.readFileSync(failedFile, "utf8");
|
|
323
|
+
if (fileContent.includes(stepName)) {
|
|
324
|
+
stepInfo.implemented = true;
|
|
325
|
+
stepInfo.mjsFile = failedFile;
|
|
326
|
+
stepInfo.functionName = stepName;
|
|
327
|
+
stepInfo.error = errorsInParsing[k].error;
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
} catch (e) {
|
|
333
|
+
console.error(`Error while checking step ${stepInfo.template} in failed files:`, e);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
314
336
|
stepInfo.implemented = stepDef ? true : false;
|
|
315
337
|
if (stepDef) {
|
|
316
338
|
stepInfo.mjsFile = stepDef.file;
|
|
@@ -4,14 +4,14 @@ import { AstBuilder, GherkinClassicTokenMatcher, Parser } from "@cucumber/gherki
|
|
|
4
4
|
import { Feature } from "./feature.js";
|
|
5
5
|
import { StepsDefinitions } from "./steps_definitions.js";
|
|
6
6
|
|
|
7
|
-
export const projectDocument = (folder, featureName = null, scenarioName = null) => {
|
|
7
|
+
export const projectDocument = (folder, featureName = null, scenarioName = null, supressErrors = false, errors = []) => {
|
|
8
8
|
const uuidFn = () => (23212).toString(16);
|
|
9
9
|
const builder = new AstBuilder(uuidFn);
|
|
10
10
|
const matcher = new GherkinClassicTokenMatcher();
|
|
11
11
|
const parser = new Parser(builder, matcher);
|
|
12
|
-
|
|
13
|
-
stepDefinition
|
|
14
|
-
|
|
12
|
+
// load the step definitions from the project folder under steps folder
|
|
13
|
+
const stepDefinition = new StepsDefinitions(folder, false);
|
|
14
|
+
stepDefinition.load(false, supressErrors, errors);
|
|
15
15
|
// read all the feature files in the project folder under features folder
|
|
16
16
|
let featureFiles = [];
|
|
17
17
|
const featuresDir = path.join(folder, "features");
|
|
@@ -27,7 +27,7 @@ export const projectDocument = (folder, featureName = null, scenarioName = null)
|
|
|
27
27
|
if (featureName && feature.feature.name !== featureName && featureFile !== featureName) {
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
30
|
-
const document = feature.generateStracture(stepDefinition, featureFile, scenarioName);
|
|
30
|
+
const document = feature.generateStracture(stepDefinition, featureFile, scenarioName, errors, supressErrors);
|
|
31
31
|
if (scenarioName && document.scenarios.length === 0) {
|
|
32
32
|
continue;
|
|
33
33
|
}
|
|
@@ -55,7 +55,8 @@ export const projectDocument = (folder, featureName = null, scenarioName = null)
|
|
|
55
55
|
// scenarioName = arg.substring(9);
|
|
56
56
|
// }
|
|
57
57
|
// }
|
|
58
|
-
//
|
|
58
|
+
// let errors = [];
|
|
59
|
+
// const documents = projectDocument(projectDir, featureName, scenarioName, true, errors);
|
|
59
60
|
// const args = process.argv.slice(2);
|
|
60
61
|
|
|
61
|
-
// console.log(JSON.stringify(
|
|
62
|
+
// console.log(JSON.stringify(documents));
|
|
@@ -54,7 +54,7 @@ class StepsDefinitions {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
load(print = true) {
|
|
57
|
+
load(print = true, supressErrors = false, errors = []) {
|
|
58
58
|
const mjsFiles = findFilesWithExtension(
|
|
59
59
|
path.join(this.baseFolder, this.isTemp ? process.env.tempFeaturesFolderPath ?? "__temp_features" : "features"),
|
|
60
60
|
"mjs"
|
|
@@ -62,18 +62,25 @@ class StepsDefinitions {
|
|
|
62
62
|
// console.log({ mjsFiles });
|
|
63
63
|
for (let i = 0; i < mjsFiles.length; i++) {
|
|
64
64
|
const mjsFile = mjsFiles[i];
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
);
|
|
65
|
+
console.log("loading step definitions from file", mjsFile);
|
|
66
|
+
const filePath = path.join(
|
|
67
|
+
this.baseFolder,
|
|
68
|
+
this.isTemp ? process.env.tempFeaturesFolderPath ?? "__temp_features" : "features",
|
|
69
|
+
mjsFile);
|
|
70
|
+
const codePage = new CodePage(filePath);
|
|
72
71
|
try {
|
|
73
72
|
codePage.generateModel();
|
|
74
73
|
} catch (error) {
|
|
75
74
|
logger.info("unable to generate model for file", mjsFile);
|
|
76
|
-
|
|
75
|
+
if(supressErrors) {
|
|
76
|
+
errors.push({
|
|
77
|
+
file: filePath,
|
|
78
|
+
error: error.message,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
else{
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
77
84
|
}
|
|
78
85
|
this.initPage(codePage, mjsFile);
|
|
79
86
|
}
|
|
@@ -197,7 +197,22 @@ class ScenarioReport {
|
|
|
197
197
|
// Increased the max retries to 3 and added exponential backoff to increase consistency but traded off availability :)
|
|
198
198
|
async _uploadScenario() {
|
|
199
199
|
try {
|
|
200
|
-
|
|
200
|
+
let scenarioDoc;
|
|
201
|
+
let attempts = 1;
|
|
202
|
+
while (attempts < MAX_RETRIES) {
|
|
203
|
+
try {
|
|
204
|
+
scenarioDoc = await this.scenarioUploadService.createScenarioDocument(this.name);
|
|
205
|
+
|
|
206
|
+
break; // exit loop if successful
|
|
207
|
+
} catch (err) {
|
|
208
|
+
attempts++;
|
|
209
|
+
await this._delay(2 ** attempts * 1000);
|
|
210
|
+
if (attempts >= MAX_RETRIES) {
|
|
211
|
+
logger.error(`Failed to upload scenario document (Attempt ${attempts})`);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
201
216
|
const scenarioDocId = scenarioDoc._id;
|
|
202
217
|
const projectId = scenarioDoc.project_id;
|
|
203
218
|
this.scenario_id = scenarioDocId;
|
|
@@ -211,7 +226,7 @@ class ScenarioReport {
|
|
|
211
226
|
logger.info("Scenario uploaded successfully");
|
|
212
227
|
this.logReportLink(projectId, scenarioDocId);
|
|
213
228
|
} catch (err) {
|
|
214
|
-
logger.error("Scenario
|
|
229
|
+
logger.error("Scenario upload failed");
|
|
215
230
|
logger.debug("Error while uploading : ", err);
|
|
216
231
|
}
|
|
217
232
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dev-blinq/cucumber_client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1198-dev",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "bin/index.js",
|
|
6
6
|
"types": "bin/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@cucumber/tag-expressions": "^6.1.1",
|
|
29
29
|
"@dev-blinq/cucumber-js": "1.0.172-dev",
|
|
30
30
|
"@faker-js/faker": "^8.1.0",
|
|
31
|
-
"automation_model": "1.0.
|
|
31
|
+
"automation_model": "1.0.723-dev",
|
|
32
32
|
"axios": "^1.7.4",
|
|
33
33
|
"chokidar": "^3.6.0",
|
|
34
34
|
"create-require": "^1.1.1",
|