@zohodesk/testinglibrary 0.1.8-stb-bdd-v9 → 0.1.8-stb-bdd-v10

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.
@@ -10,7 +10,7 @@ var _fileUtils = require("../../../utils/fileUtils");
10
10
  var _path = _interopRequireDefault(require("path"));
11
11
  var _pathConfig = require("../../config/pathConfig");
12
12
  globalThis.inputsParamterMap = new Map();
13
- async function readStepFile() {
13
+ function readStepFile() {
14
14
  const stepFilePath = (0, _pathConfig.getStepFilePath)();
15
15
  const processedSpecFile = [];
16
16
  return new Promise(resolve => {
@@ -18,6 +18,7 @@ function stepFileCreation(featureContent, stepFilename, featureFilePath) {
18
18
  (0, _fileUtils.writeFileContents)(stepsFilePath, stepsSnippets);
19
19
  }
20
20
  async function generateSpecFiles() {
21
+ await (0, _extractTestInputs.readStepFile)();
21
22
  const featureFilePattern = (0, _pathConfig.getFeatureFilePath)();
22
23
  const generatedFolderPath = _path.default.resolve(process.cwd(), 'uat', '.feature-gen');
23
24
  if (!(0, _fileUtils.checkIfFileExists)(generatedFolderPath)) {
@@ -25,7 +26,6 @@ async function generateSpecFiles() {
25
26
  recursive: true
26
27
  });
27
28
  }
28
- await (0, _extractTestInputs.readStepFile)();
29
29
  _fastGlob.default.globSync(featureFilePattern, {
30
30
  dot: true,
31
31
  cwd: process.cwd()
@@ -3,15 +3,24 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.TESTING_LIBRARY = void 0;
7
- exports.testBackGround = testBackGround;
8
6
  exports.testCase = testCase;
9
7
  exports.testFile = testFile;
10
8
  exports.testStep = testStep;
11
9
  exports.testSuite = testSuite;
12
- const TESTING_LIBRARY = exports.TESTING_LIBRARY = '@zohodesk/testinglibrary';
13
- function testStep(keyword, description, browserObject, testData, options) {
14
- return `await test.step("${keyword} ${description}",async() => {
10
+ const TESTING_LIBRARY = '@zohodesk/testinglibrary';
11
+ function stepReportHandle(Steps, Example) {
12
+ var _steps = [...Steps];
13
+ var resultSteps;
14
+ const medium = Math.random();
15
+ resultSteps = _steps.join(medium);
16
+ Object.keys(Example).forEach(keys => {
17
+ const newRegex = new RegExp(keys, 'g');
18
+ resultSteps = resultSteps.replace(newRegex, Example[keys]);
19
+ });
20
+ return [...resultSteps.split(medium)];
21
+ }
22
+ function testStep(keyword, description, browserObject, testData, stepDescription, options) {
23
+ return `await test.step("${keyword.trim()} : ${stepDescription}",async() => {
15
24
  await $${keyword}('${description}')(${browserObject},${testData})
16
25
  })`;
17
26
  }
@@ -27,7 +36,7 @@ function testCase(steps, examples, description, browserObjects, tags, option) {
27
36
  return val.concat('-');
28
37
  });
29
38
  let avoidRepitationDescription = exampleDescription.join('').concat(`Example-${index + 1}`);
30
- return testBlock(avoidRepitationDescription, steps, browserObjects);
39
+ return testBlock(avoidRepitationDescription, stepReportHandle(steps, examples), browserObjects);
31
40
  });
32
41
  return testSuite(description, exmapleScenario.join('\n'), tags);
33
42
  }
@@ -50,9 +59,4 @@ function testFile(testCase, relativeFilePath, $tags, backgroundScenario = " ", o
50
59
  ${backgroundScenario}
51
60
  ${testCase.join('')}
52
61
  `;
53
- }
54
- function testBackGround(backgroundSteps, inputs) {
55
- return ` test.beforeEach(async ({${inputs.join(',')}}) => { \n
56
- ${backgroundSteps.join(`\n`)}
57
- });`;
58
62
  }
@@ -16,9 +16,6 @@ function testSnippet(featureContent, featureFilePath) {
16
16
  const _constructStep = scenarioSnippet(scenario);
17
17
  currentScenarios.push(_constructStep);
18
18
  });
19
- // if(featureContent.featureBackGround?.length){
20
- // return testFile(currentScenarios,featureFilePath,$tags,backgroundHandle(featureContent.featureBackGround))
21
- // }
22
19
  return (0, _stepsnippets.testFile)(currentScenarios, featureFilePath, $tags);
23
20
  }
24
21
  function extactStepArgs(step) {
@@ -54,7 +51,7 @@ function scenarioSnippet(scenario) {
54
51
  } = extactStepArgs(step.stepDescription);
55
52
  var input = inputsParamterMap.get(`'${refactoredStep}'`);
56
53
  currentInputs.push(input);
57
- currentStep.push((0, _stepsnippets.testStep)(step.keyword, refactoredStep, input, currentArgument.join(',')));
54
+ currentStep.push((0, _stepsnippets.testStep)(step.keyword, refactoredStep, input, currentArgument.join(','), step.stepDescription));
58
55
  return;
59
56
  });
60
57
  const pageObject = browserObjectHandle(currentInputs);
@@ -84,33 +81,4 @@ function handleInputTags(scenario) {
84
81
  return {
85
82
  [scenario.scenariodescription]: scenario.scenarioTags
86
83
  };
87
- }
88
-
89
- // function backGroundStep(backGroundScenario){
90
- // const currentBackGroundStep = []
91
- // const backgroundStepInput = []
92
- // backGroundScenario.background.forEach((backGroundStep) => {
93
- // var { refactoredStep, currentArgument } = extactStepArgs(backGroundStep.stepDescription);
94
- // var input = inputsParamterMap.get(`'${refactoredStep}'`);
95
- // backgroundStepInput.push(input)
96
- // currentBackGroundStep.push(testStep(backGroundStep.keyword, refactoredStep, input, currentArgument.join(',')));
97
- // return;
98
- // })
99
- // return
100
- // }
101
-
102
- function backgroundHandle(background) {
103
- const currentBackground = [];
104
- const backgroundInput = [];
105
- background.forEach(b_scenario => {
106
- var {
107
- refactoredStep,
108
- currentArgument
109
- } = extactStepArgs(b_scenario.stepDescription);
110
- var input = inputsParamterMap.get(`'${refactoredStep}'`);
111
- backgroundInput.push(input);
112
- currentBackground.push((0, _stepsnippets.testStep)(b_scenario.keyword, refactoredStep, input, currentArgument.join(',')));
113
- return;
114
- });
115
- return (0, _stepsnippets.testBackGround)(currentBackground, browserObjectHandle(backgroundInput));
116
84
  }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ function HeavyTask() {
4
+ return new Promise(resolve => {
5
+ setTimeout(() => {
6
+ console.log('Intensive Task Done');
7
+ resolve('done');
8
+ }, 10000);
9
+ });
10
+ }
11
+ async function intensive() {
12
+ await HeavyTask();
13
+ }
14
+ intensive();
15
+ console.log('Breaked ............');
@@ -0,0 +1,12 @@
1
+ // const { workerData, Worker } = require('worker_threads')
2
+
3
+ // new Worker().performance()
4
+
5
+ // const featureFiles = fg.globSync(featureFilePattern, { dot: true, cwd: process.cwd() });
6
+
7
+ // // Split the files into chunks for parallel processing
8
+ // const chunkSize = Math.ceil(featureFiles.length / os.cpus().length);
9
+ // const fileChunks = Array.from({ length: os.cpus().length }, (_, index) =>
10
+ // featureFiles.slice(index * chunkSize, (index + 1) * chunkSize)
11
+ // );
12
+ "use strict";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.1.8-stb-bdd-v9",
3
+ "version": "0.1.8-stb-bdd-v10",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {