@zohodesk/testinglibrary 0.1.8-stb-bdd-v18 → 0.1.8-stb-bdd-v20

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.
@@ -25,8 +25,8 @@ function getTestData(description, argument) {
25
25
 
26
26
  /** Both Input and Step Table Passed*/
27
27
  if (stepArguments.input && stepArguments.steptable) {
28
- const stepInput = Object.values(stepArguments.currentArgument).pop() || 'null';
29
- return [stepInput, stepArguments.dataTableStep];
28
+ const stepInput = Object.values(stepArguments.currentArgument) || [null];
29
+ return [...stepInput, stepArguments.dataTableStep];
30
30
  }
31
31
 
32
32
  /** Input Passed */
@@ -4,12 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.throwNotImplementError = throwNotImplementError;
7
+ exports.throwProperStepImplementError = throwProperStepImplementError;
7
8
  var _logger = require("../../utils/logger");
8
9
  function throwNotImplementError(step, stepInSpec, keyword) {
9
10
  return _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `
10
- \n ${step} - Not Implemented
11
- \n ${keyword}(${stepInSpec},async({page}) => {
11
+ \n ${step} - Step Not Implemented
12
+ \n ${keyword}(${stepInSpec}, async ({page}) => {
12
13
  \n ..........................................
13
14
  \n }
14
15
  `);
16
+ }
17
+ function throwProperStepImplementError(filePath, description = "", options = null) {
18
+ return _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `
19
+ \n Page Fixtures and Test Data are Not Used is Steps :(
20
+ \n File : ${filePath}
21
+ \n MisMatch Steps Pattern !
22
+ `);
15
23
  }
@@ -9,7 +9,7 @@ var _fastGlob = _interopRequireDefault(require("fast-glob"));
9
9
  var _fileUtils = require("../../../utils/fileUtils");
10
10
  var _path = _interopRequireDefault(require("path"));
11
11
  var _pathConfig = require("../../config/pathConfig");
12
- var _logger = require("../../../utils/logger");
12
+ var _throwError = require("../../errors/throwError");
13
13
  globalThis.testDataMap = new Map();
14
14
  function createStepDataMap() {
15
15
  const stepFilePath = (0, _pathConfig.getStepFilePath)();
@@ -36,10 +36,17 @@ function extractPageFixtures(filePath) {
36
36
  });
37
37
  }
38
38
  function extractInputFrmStep(trimmedStep, filePath) {
39
+ var toRemovePattern = trimmedStep.match(/async\s*\(([^)]*)\)/)[1].match(/{(.*?)}/);
40
+ var InputNames = trimmedStep.match(/async\s*\(([^)]*)\)/)[1].replace(toRemovePattern[0], "$null") || [];
39
41
  try {
40
- return trimmedStep.split(' ').slice(1).join('').match(/\((.*?)\)/)[1].match(/\{(.*?)\}/g).pop() || [""].pop();
42
+ var _InputNames$split;
43
+ return {
44
+ stepPageFixtureName: trimmedStep.split(' ').slice(1).join('').match(/\((.*?)\)/)[1].match(/\{(.*?)\}/g).pop() || [false].pop(),
45
+ stepInputKey: ((_InputNames$split = InputNames.split(',')) === null || _InputNames$split === void 0 || (_InputNames$split = _InputNames$split.slice(1)) === null || _InputNames$split === void 0 ? void 0 : _InputNames$split.map(input => `"${input}"`)) || []
46
+ };
41
47
  } catch (error) {
42
- _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `${filePath} - Steps Has MisMatched Pattern`);
48
+ // Logger.log(Logger.FAILURE_TYPE,`${filePath} - Steps Has MisMatched Pattern`)
49
+ (0, _throwError.throwProperStepImplementError)(filePath);
43
50
  process.exit(0);
44
51
  }
45
52
  }
@@ -23,51 +23,66 @@ function testDataCreation() {
23
23
  var body, header;
24
24
  var gherkinDocument = (0, _parserCucumber.default)((0, _fileUtils.readFileContents)(_path.default.resolve(process.cwd(), filePath), 'utf-8'));
25
25
  gherkinDocument.feature.children.forEach($scenario => {
26
- var _$scenario$scenario, _$scenario$scenario2;
27
- const $currentScenario = {
28
- currentArgument: '',
29
- dataTableStep: '',
30
- inputParameter: '',
31
- input: false,
32
- steptable: false,
33
- scenarioTable: false
34
- };
26
+ var _$scenario$scenario, _$scenario$scenario3, _$scenario$scenario4;
35
27
  if ($scenario !== null && $scenario !== void 0 && $scenario.background) {
36
28
  $scenario.scenario = {
37
29
  ...$scenario.background,
38
30
  examples: []
39
31
  };
40
32
  }
41
- (_$scenario$scenario = $scenario.scenario) === null || _$scenario$scenario === void 0 || _$scenario$scenario.steps.forEach(step => {
42
- var _step$dataTable;
43
- const {
44
- convertedStep,
45
- currentArgument
46
- } = (0, _testStructure.extractStepArgument)(step.text);
47
- if (Object.values(currentArgument).length && !$scenario.scenario.examples.length) {
48
- $currentScenario.currentArgument = currentArgument;
49
- $currentScenario.input = true;
50
- } else {
51
- globalTestdata.set(convertedStep, {});
52
- }
53
- const dataTableStep = [];
54
- step === null || step === void 0 || (_step$dataTable = step.dataTable) === null || _step$dataTable === void 0 || _step$dataTable.rows.forEach(cell => {
55
- const Table = cell.cells.map(element => element.value);
56
- dataTableStep.push(Table);
33
+ if ($scenario !== null && $scenario !== void 0 && (_$scenario$scenario = $scenario.scenario) !== null && _$scenario$scenario !== void 0 && _$scenario$scenario.steps) {
34
+ var _$scenario$scenario2;
35
+ (_$scenario$scenario2 = $scenario.scenario) === null || _$scenario$scenario2 === void 0 || _$scenario$scenario2.steps.forEach(step => {
36
+ var _step$dataTable;
37
+ var $currentStep = {
38
+ currentArgument: '',
39
+ dataTableStep: '',
40
+ inputParameter: '',
41
+ input: false,
42
+ steptable: false,
43
+ scenarioTable: false
44
+ };
45
+ const {
46
+ convertedStep,
47
+ currentArgument
48
+ } = (0, _testStructure.extractStepArgument)(step.text);
49
+ if (Object.values(currentArgument).length && !$scenario.scenario.examples.length) {
50
+ $currentStep.currentArgument = currentArgument;
51
+ $currentStep.input = true;
52
+ } else {
53
+ $currentStep.currentArgument = [];
54
+ $currentStep.input = false;
55
+ }
56
+ const dataTableStep = [];
57
+ step === null || step === void 0 || (_step$dataTable = step.dataTable) === null || _step$dataTable === void 0 || _step$dataTable.rows.forEach(cell => {
58
+ const Table = cell.cells.map(element => element.value);
59
+ dataTableStep.push(Table);
60
+ });
61
+ if (step !== null && step !== void 0 && step.dataTable) {
62
+ $currentStep.dataTableStep = dataTableStep;
63
+ $currentStep.steptable = true;
64
+ }
65
+ globalTestdata.set(convertedStep, Object.assign({}, $currentStep));
57
66
  });
58
- if (step !== null && step !== void 0 && step.dataTable) {
59
- $currentScenario.dataTableStep = dataTableStep;
60
- $currentScenario.steptable = true;
61
- }
62
- globalTestdata.set(convertedStep, Object.assign({}, $currentScenario));
63
- });
64
- if (typeof $scenario.background === Object) {
67
+ }
68
+ if ($scenario.background && typeof $scenario.background === Object) {
65
69
  return;
66
70
  }
67
- if ((_$scenario$scenario2 = $scenario.scenario) !== null && _$scenario$scenario2 !== void 0 && (_$scenario$scenario2 = _$scenario$scenario2.examples) !== null && _$scenario$scenario2 !== void 0 && _$scenario$scenario2.length) {
68
- var _$scenario$scenario3;
71
+ if (!((_$scenario$scenario3 = $scenario.scenario) !== null && _$scenario$scenario3 !== void 0 && (_$scenario$scenario3 = _$scenario$scenario3.examples) !== null && _$scenario$scenario3 !== void 0 && _$scenario$scenario3.length)) {
72
+ return;
73
+ }
74
+ if ((_$scenario$scenario4 = $scenario.scenario) !== null && _$scenario$scenario4 !== void 0 && (_$scenario$scenario4 = _$scenario$scenario4.examples) !== null && _$scenario$scenario4 !== void 0 && _$scenario$scenario4.length) {
75
+ var _$scenario$scenario5;
76
+ var $currentExampleSteps = {
77
+ currentArgument: '',
78
+ dataTableStep: '',
79
+ inputParameter: '',
80
+ input: false,
81
+ steptable: false,
82
+ scenarioTable: false
83
+ };
69
84
  exampleSteps = $scenario.scenario.steps.map(element => (0, _testStructure.extractStepArgument)(element.text).convertedStep);
70
- (_$scenario$scenario3 = $scenario.scenario) === null || _$scenario$scenario3 === void 0 || _$scenario$scenario3.examples.map(example => {
85
+ (_$scenario$scenario5 = $scenario.scenario) === null || _$scenario$scenario5 === void 0 || _$scenario$scenario5.examples.map(example => {
71
86
  var _example$tableHeader;
72
87
  body = example === null || example === void 0 ? void 0 : example.tableBody.map(cell => {
73
88
  return cell === null || cell === void 0 ? void 0 : cell.cells.map(example => example.value);
@@ -78,9 +93,9 @@ function testDataCreation() {
78
93
  });
79
94
  const inputParameter = testDataExtraction(header, body);
80
95
  exampleSteps.forEach(step => {
81
- $currentScenario.inputParameter = Object.assign([], inputParameter);
82
- $currentScenario.scenarioTable = true;
83
- globalTestdata.set(step, Object.assign({}, $currentScenario));
96
+ $currentExampleSteps.inputParameter = Object.assign([], inputParameter);
97
+ $currentExampleSteps.scenarioTable = true;
98
+ globalTestdata.set(step, Object.assign({}, $currentExampleSteps));
84
99
  });
85
100
  }
86
101
  });
@@ -54,12 +54,12 @@ function scenarioSnippet(scenario) {
54
54
  } = extractStepArgument(step.stepDescription);
55
55
  var pageFixtureUsed_Step = testDataMap.get(convertedStep) || null;
56
56
  /** Step Implementation Check (Walk Through Approach)*/
57
- if (!pageFixtureUsed_Step) {
57
+ if (!pageFixtureUsed_Step.stepPageFixtureName) {
58
58
  (0, _throwError.throwNotImplementError)(step.stepDescription, convertedStep, step.keyword);
59
59
  process.exit(0);
60
60
  }
61
- currentInputs.push(pageFixtureUsed_Step);
62
- currentStep.push((0, _stepsnippets.testStep)(step.keyword, convertedStep, pageFixtureUsed_Step, currentArgument.join(','), step.stepDescription));
61
+ currentInputs.push(pageFixtureUsed_Step.stepPageFixtureName);
62
+ currentStep.push((0, _stepsnippets.testStep)(step.keyword, convertedStep, pageFixtureUsed_Step.stepPageFixtureName, pageFixtureUsed_Step.stepInputKey.join(','), step.stepDescription));
63
63
  return;
64
64
  });
65
65
  const pageFixtures = pageFixtureFilter(currentInputs);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.1.8-stb-bdd-v18",
3
+ "version": "0.1.8-stb-bdd-v20",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {