@dev-blinq/cucumber_client 1.0.1354-dev → 1.0.1355-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.
@@ -1,3 +1,5 @@
1
+ import { IdGenerator } from "@cucumber/messages";
2
+ import { AstBuilder, GherkinClassicTokenMatcher, Parser, compile } from "@cucumber/gherkin";
1
3
  import { loadConfiguration, loadSupport, runCucumber } from "@dev-blinq/cucumber-js/api";
2
4
  import fs from "fs";
3
5
  import os from "os";
@@ -449,6 +451,25 @@ class Scenario {
449
451
  return this.scenarioText;
450
452
  }
451
453
  }
454
+
455
+ const getDocumentAndPickel = (featureName, featureContent, scenarioName) => {
456
+ const newId = IdGenerator.uuid();
457
+ const builder = new AstBuilder(newId);
458
+ const matcher = new GherkinClassicTokenMatcher();
459
+
460
+ const parser = new Parser(builder, matcher);
461
+
462
+ // normalize the path to start with featuers/ if it's not cut the featureFielPath to only the part after features/
463
+ let uri = `features/${featureName}.feature`;
464
+
465
+ const gherkinDocument = parser.parse(featureContent, newId);
466
+ const pickles = compile(gherkinDocument, uri, newId);
467
+ // Step 3: Find the specific scenario Pickle
468
+ const pickle = pickles.find((pickle) => {
469
+ return pickle.name === scenarioName;
470
+ });
471
+ return { gherkinDocument, pickle };
472
+ };
452
473
  const scenarioResolution = async (featureFilePath) => {
453
474
  if (!fs.existsSync(featureFilePath)) {
454
475
  throw new Error(`Feature file ${featureFilePath} does not exist`);
@@ -524,4 +545,4 @@ const scenarioResolution = async (featureFilePath) => {
524
545
  }
525
546
  }
526
547
  };
527
- export { Feature, Scenario, Step, DataTable, Examples, scenarioResolution };
548
+ export { Feature, Scenario, Step, DataTable, Examples, scenarioResolution, getDocumentAndPickel };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-blinq/cucumber_client",
3
- "version": "1.0.1354-dev",
3
+ "version": "1.0.1355-dev",
4
4
  "description": " ",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",