@zohodesk/testinglibrary 0.1.8-stb-bdd-v3 → 0.1.8-stb-bdd-v5
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.
- package/build/bdd-poc/test/stepGenerate/stepFileGenerate.js +1 -1
- package/build/bdd-poc/test/stepGenerate/stepsnippets.js +3 -1
- package/build/bdd-poc/test/testDataMap.js +69 -59
- package/build/bdd-poc/test/testStructure.js +22 -4
- package/build/core/playwright/setup/config-creator.js +2 -4
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ var _fileUtils = require("../../../utils/fileUtils");
|
|
|
13
13
|
var _extractTestInputs = require("./extractTestInputs");
|
|
14
14
|
var _pathConfig = require("../../config/pathConfig");
|
|
15
15
|
function stepFileCreation(featureContent, stepFilename, featureFilePath) {
|
|
16
|
-
const stepsFilePath = _path.default.resolve(process.cwd(), 'uat', 'feature-gen', stepFilename);
|
|
16
|
+
const stepsFilePath = _path.default.resolve(process.cwd(), 'uat', '.feature-gen', stepFilename);
|
|
17
17
|
const stepsSnippets = (0, _testStructure.testSnippet)(featureContent, featureFilePath);
|
|
18
18
|
(0, _fileUtils.writeFileContents)(stepsFilePath, stepsSnippets);
|
|
19
19
|
}
|
|
@@ -11,7 +11,9 @@ exports.testStep = testStep;
|
|
|
11
11
|
exports.testSuite = testSuite;
|
|
12
12
|
const TESTING_LIBRARY = exports.TESTING_LIBRARY = '@zohodesk/testinglibrary';
|
|
13
13
|
function testStep(keyword, description, browserObject, testData, options) {
|
|
14
|
-
return `
|
|
14
|
+
return `test.step("${keyword} ${description}",async() => {
|
|
15
|
+
await $${keyword}('${description}')(${browserObject},${testData})
|
|
16
|
+
})`;
|
|
15
17
|
}
|
|
16
18
|
function testSuite(description, scenariotestBlock, tags, options = null) {
|
|
17
19
|
return `\ntest.describe('${description}${tags.join(" ")}', () => {
|
|
@@ -11,74 +11,79 @@ var _fileUtils = require("../../utils/fileUtils");
|
|
|
11
11
|
var _path = _interopRequireDefault(require("path"));
|
|
12
12
|
var _parserCucumber = _interopRequireDefault(require("./cucumber/parserCucumber"));
|
|
13
13
|
var _pathConfig = require("../config/pathConfig");
|
|
14
|
-
|
|
14
|
+
function testDataCreation() {
|
|
15
15
|
var exampleSteps = [];
|
|
16
16
|
const globalTestdata = new Map();
|
|
17
17
|
const testDataFeatureFilePath = (0, _pathConfig.getFeatureFilePath)();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
refactoredStep,
|
|
38
|
-
currentArgument
|
|
39
|
-
} = (0, _testStructure.extactStepArgs)(step.text);
|
|
40
|
-
if (Object.values(currentArgument).length && !$scenario.scenario.examples.length) {
|
|
41
|
-
$currentScenario.currentArgument = currentArgument;
|
|
42
|
-
$currentScenario.input = true;
|
|
43
|
-
} else {
|
|
44
|
-
globalTestdata.set(refactoredStep, {});
|
|
18
|
+
return new Promise(resolve => {
|
|
19
|
+
_fastGlob.default.globSync(testDataFeatureFilePath, {
|
|
20
|
+
dot: true,
|
|
21
|
+
cwd: process.cwd()
|
|
22
|
+
}).forEach(filePath => {
|
|
23
|
+
var body, header;
|
|
24
|
+
var gherkinDocument = (0, _parserCucumber.default)((0, _fileUtils.readFileContents)(_path.default.resolve(process.cwd(), filePath), 'utf-8'));
|
|
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
|
+
};
|
|
35
|
+
if ($scenario !== null && $scenario !== void 0 && $scenario.background) {
|
|
36
|
+
$scenario.scenario = $scenario.background;
|
|
45
37
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
38
|
+
(_$scenario$scenario = $scenario.scenario) === null || _$scenario$scenario === void 0 || _$scenario$scenario.steps.forEach(step => {
|
|
39
|
+
var _step$dataTable;
|
|
40
|
+
const {
|
|
41
|
+
refactoredStep,
|
|
42
|
+
currentArgument
|
|
43
|
+
} = (0, _testStructure.extactStepArgs)(step.text);
|
|
44
|
+
if (Object.values(currentArgument).length && !$scenario.scenario.examples.length) {
|
|
45
|
+
$currentScenario.currentArgument = currentArgument;
|
|
46
|
+
$currentScenario.input = true;
|
|
47
|
+
} else {
|
|
48
|
+
globalTestdata.set(refactoredStep, {});
|
|
49
|
+
}
|
|
50
|
+
const dataTableStep = [];
|
|
51
|
+
step === null || step === void 0 || (_step$dataTable = step.dataTable) === null || _step$dataTable === void 0 || _step$dataTable.rows.forEach(cell => {
|
|
52
|
+
const Table = cell.cells.map(element => element.value);
|
|
53
|
+
dataTableStep.push(Table);
|
|
54
|
+
});
|
|
55
|
+
if (step.dataTable) {
|
|
56
|
+
$currentScenario.dataTableStep = dataTableStep;
|
|
57
|
+
$currentScenario.steptable = true;
|
|
58
|
+
}
|
|
59
|
+
globalTestdata.set(refactoredStep, Object.assign({}, $currentScenario));
|
|
50
60
|
});
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
$currentScenario.steptable = true;
|
|
61
|
+
if (typeof $scenario.background === Object) {
|
|
62
|
+
return;
|
|
54
63
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return cell === null || cell === void 0 ? void 0 : cell.cells.map(example => example.value);
|
|
64
|
+
if ((_$scenario$scenario2 = $scenario.scenario) !== null && _$scenario$scenario2 !== void 0 && (_$scenario$scenario2 = _$scenario$scenario2.examples) !== null && _$scenario$scenario2 !== void 0 && _$scenario$scenario2.length) {
|
|
65
|
+
var _$scenario$scenario3;
|
|
66
|
+
exampleSteps = $scenario.scenario.steps.map(element => (0, _testStructure.extactStepArgs)(element.text).refactoredStep);
|
|
67
|
+
(_$scenario$scenario3 = $scenario.scenario) === null || _$scenario$scenario3 === void 0 || _$scenario$scenario3.examples.map(example => {
|
|
68
|
+
var _example$tableHeader;
|
|
69
|
+
body = example === null || example === void 0 ? void 0 : example.tableBody.map(cell => {
|
|
70
|
+
return cell === null || cell === void 0 ? void 0 : cell.cells.map(example => example.value);
|
|
71
|
+
});
|
|
72
|
+
header = example === null || example === void 0 || (_example$tableHeader = example.tableHeader) === null || _example$tableHeader === void 0 ? void 0 : _example$tableHeader.cells.map(exampleHead => {
|
|
73
|
+
return exampleHead.value;
|
|
74
|
+
});
|
|
67
75
|
});
|
|
68
|
-
|
|
69
|
-
|
|
76
|
+
const inputParameter = testDataExtraction(header, body);
|
|
77
|
+
exampleSteps.forEach(step => {
|
|
78
|
+
$currentScenario.inputParameter = Object.assign([], inputParameter);
|
|
79
|
+
$currentScenario.scenarioTable = true;
|
|
80
|
+
globalTestdata.set(step, Object.assign({}, $currentScenario));
|
|
70
81
|
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
exampleSteps.forEach(step => {
|
|
74
|
-
$currentScenario.inputParameter = Object.assign([], inputParameter);
|
|
75
|
-
$currentScenario.scenarioTable = true;
|
|
76
|
-
globalTestdata.set(step, Object.assign({}, $currentScenario));
|
|
77
|
-
});
|
|
78
|
-
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
79
84
|
});
|
|
85
|
+
resolve(globalTestdata);
|
|
80
86
|
});
|
|
81
|
-
return globalTestdata;
|
|
82
87
|
}
|
|
83
88
|
function testDataExtraction(tableHeader, tableBody) {
|
|
84
89
|
const result = [];
|
|
@@ -94,4 +99,9 @@ function testDataExtraction(tableHeader, tableBody) {
|
|
|
94
99
|
return;
|
|
95
100
|
}
|
|
96
101
|
return [...result];
|
|
97
|
-
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// handle length of example
|
|
105
|
+
// if($scenario?.background){
|
|
106
|
+
// $scenario.scenario = $scenario.background
|
|
107
|
+
// }
|
|
@@ -8,7 +8,6 @@ exports.testSnippet = testSnippet;
|
|
|
8
8
|
var _stringManipulation = require("../utils/stringManipulation");
|
|
9
9
|
var _stepsnippets = require("./stepGenerate/stepsnippets");
|
|
10
10
|
function testSnippet(featureContent, featureFilePath) {
|
|
11
|
-
var _featureContent$featu;
|
|
12
11
|
var currentScenarios = [];
|
|
13
12
|
var $tags = {};
|
|
14
13
|
featureContent.scenarios.forEach(scenario => {
|
|
@@ -17,9 +16,9 @@ function testSnippet(featureContent, featureFilePath) {
|
|
|
17
16
|
const _constructStep = scenarioSnippet(scenario);
|
|
18
17
|
currentScenarios.push(_constructStep);
|
|
19
18
|
});
|
|
20
|
-
if
|
|
21
|
-
|
|
22
|
-
}
|
|
19
|
+
// if(featureContent.featureBackGround?.length){
|
|
20
|
+
// return testFile(currentScenarios,featureFilePath,$tags,backgroundHandle(featureContent.featureBackGround))
|
|
21
|
+
// }
|
|
23
22
|
return (0, _stepsnippets.testFile)(currentScenarios, featureFilePath, $tags);
|
|
24
23
|
}
|
|
25
24
|
function extactStepArgs(step) {
|
|
@@ -41,8 +40,13 @@ function extactStepArgs(step) {
|
|
|
41
40
|
};
|
|
42
41
|
}
|
|
43
42
|
function scenarioSnippet(scenario) {
|
|
43
|
+
var _scenario$background;
|
|
44
44
|
var currentStep = [];
|
|
45
45
|
var currentInputs = [];
|
|
46
|
+
// To Add BackGround As Steps :
|
|
47
|
+
if ((scenario === null || scenario === void 0 || (_scenario$background = scenario.background) === null || _scenario$background === void 0 ? void 0 : _scenario$background.length) >= 1) {
|
|
48
|
+
scenario.steps = [...scenario.background, ...scenario.steps];
|
|
49
|
+
}
|
|
46
50
|
scenario.steps.forEach(step => {
|
|
47
51
|
var {
|
|
48
52
|
refactoredStep,
|
|
@@ -81,6 +85,20 @@ function handleInputTags(scenario) {
|
|
|
81
85
|
[scenario.scenariodescription]: scenario.scenarioTags
|
|
82
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
|
+
|
|
84
102
|
function backgroundHandle(background) {
|
|
85
103
|
const currentBackground = [];
|
|
86
104
|
const backgroundInput = [];
|
|
@@ -47,12 +47,10 @@ const testOptions = (0, _configUtils.getTestUseOptions)({
|
|
|
47
47
|
*
|
|
48
48
|
* @returns {import('@playwright/test').PlaywrightTestConfig}
|
|
49
49
|
*/
|
|
50
|
-
function getPlaywrightConfig() {
|
|
50
|
+
async function getPlaywrightConfig() {
|
|
51
51
|
globalThis.globalStepMap = new Map();
|
|
52
52
|
(0, _runner.stepFileMap)();
|
|
53
|
-
(0, _testDataMap.testDataCreation)()
|
|
54
|
-
globalThis.globalTestdata = inputs;
|
|
55
|
-
});
|
|
53
|
+
globalThis.globalTestdata = await (0, _testDataMap.testDataCreation)();
|
|
56
54
|
return {
|
|
57
55
|
testDir,
|
|
58
56
|
outputDir: _path.default.join(process.cwd(), 'uat', 'test-results'),
|