@dev-blinq/cucumber_client 1.0.1659-dev → 1.0.1661-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.
|
@@ -292,25 +292,46 @@ const GherkinToObject = (gherkin) => {
|
|
|
292
292
|
|
|
293
293
|
// remove lines starting with "Scenario:" or "Scenario Outline:" that contain the scenario name until the next scenario and then append the new scenario content
|
|
294
294
|
// assumes that there are no multiple scenarios with the same name and having comments and tags in each scenario
|
|
295
|
-
function updateExistingScenario({
|
|
295
|
+
function updateExistingScenario({
|
|
296
|
+
featureFileContent,
|
|
297
|
+
scenarioName: newScenarioName,
|
|
298
|
+
scenarioContent: newScenarioContent,
|
|
299
|
+
}) {
|
|
296
300
|
const featureFileObject = GherkinToObject(featureFileContent);
|
|
297
301
|
if (featureFileObject.error) return "error";
|
|
302
|
+
|
|
298
303
|
const results = [];
|
|
299
|
-
let skipScenarioIndex = -1;
|
|
300
304
|
results.push(`Feature: ${featureFileObject.featureName}`);
|
|
305
|
+
|
|
306
|
+
let indexOfScenarioToUpdate = -1;
|
|
307
|
+
|
|
308
|
+
for (let i = 0; i < featureFileObject.scenarios.length; i++) {
|
|
309
|
+
if (featureFileObject.scenarios[i].name === newScenarioName) {
|
|
310
|
+
indexOfScenarioToUpdate = i;
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
301
315
|
for (let i = 0; i < featureFileObject.scenarios.length; i++) {
|
|
302
316
|
const scenario = featureFileObject.scenarios[i];
|
|
303
|
-
|
|
304
|
-
|
|
317
|
+
|
|
318
|
+
if (i === indexOfScenarioToUpdate) {
|
|
319
|
+
results.push("");
|
|
320
|
+
results.push(newScenarioContent.trim());
|
|
321
|
+
results.push("");
|
|
305
322
|
continue;
|
|
306
323
|
}
|
|
307
|
-
|
|
324
|
+
|
|
325
|
+
let scenarioHeader = `${scenario.hasParams ? "Scenario Outline" : "Scenario"}: ${scenario.name}`;
|
|
308
326
|
let tagsLine;
|
|
327
|
+
|
|
309
328
|
if (scenario.tags?.length > 0) {
|
|
310
|
-
tagsLine =
|
|
329
|
+
tagsLine = scenario.tags.map((t) => `@${t}`).join(" ");
|
|
311
330
|
}
|
|
331
|
+
|
|
312
332
|
if (tagsLine) results.push("\t" + tagsLine);
|
|
313
|
-
results.push(`\t${
|
|
333
|
+
results.push(`\t${scenarioHeader}`);
|
|
334
|
+
|
|
314
335
|
for (const step of scenario.steps) {
|
|
315
336
|
if (step.type === "examples") {
|
|
316
337
|
results.push(`\t\tExamples:`);
|
|
@@ -323,12 +344,10 @@ function updateExistingScenario({ featureFileContent, scenarioName, scenarioCont
|
|
|
323
344
|
}
|
|
324
345
|
results.push("");
|
|
325
346
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
finalContent = results.join("\n") + "\n" + scenarioContent;
|
|
329
|
-
}
|
|
330
|
-
return finalContent;
|
|
347
|
+
|
|
348
|
+
return results.join("\n");
|
|
331
349
|
}
|
|
350
|
+
|
|
332
351
|
export async function updateFeatureFile({ featureName, scenario, override, projectDir }) {
|
|
333
352
|
const featureFilePath = path.join(projectDir, "features", featureName + ".feature");
|
|
334
353
|
const isFeatureFileExists = existsSync(featureFilePath);
|