@zohodesk/testinglibrary 0.1.8-exp-bdd-v8 → 0.1.8-exp-bdd-v9
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/cucumber/featureFileParer.js +3 -1
- package/build/bdd-poc/test/stepGenerate/stepsnippets.js +16 -8
- package/build/bdd-poc/test/testDataMap.js +4 -4
- package/build/bdd-poc/test/testStructure.js +21 -5
- package/build/bdd-poc/utils/stringManipulation.js +1 -1
- package/package.json +1 -1
|
@@ -12,7 +12,8 @@ function parseFeature(featureFileContent) {
|
|
|
12
12
|
var currentFeature = {
|
|
13
13
|
feature: "",
|
|
14
14
|
featureTags: [],
|
|
15
|
-
scenarios: []
|
|
15
|
+
scenarios: [],
|
|
16
|
+
featureBackGround: []
|
|
16
17
|
};
|
|
17
18
|
var isBackgroundExist;
|
|
18
19
|
currentFeature.feature = gherkinDocument.feature.name;
|
|
@@ -63,6 +64,7 @@ function parseFeature(featureFileContent) {
|
|
|
63
64
|
scenarioSteps.background = isBackgroundExist || [];
|
|
64
65
|
currentFeature.scenarios.push(scenarioSteps);
|
|
65
66
|
});
|
|
67
|
+
currentFeature.featureBackGround = currentFeature.scenarios[0].background;
|
|
66
68
|
return currentFeature;
|
|
67
69
|
}
|
|
68
70
|
function testDataExtraction(tableHeader, tableBody) {
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TESTING_LIBRARY = void 0;
|
|
7
|
+
exports.testBackGround = testBackGround;
|
|
7
8
|
exports.testCase = testCase;
|
|
8
9
|
exports.testFile = testFile;
|
|
9
10
|
exports.testStep = testStep;
|
|
@@ -12,26 +13,28 @@ const TESTING_LIBRARY = exports.TESTING_LIBRARY = '@zohodesk/testinglibrary';
|
|
|
12
13
|
function testStep(keyword, description, browserObject, testData, options) {
|
|
13
14
|
return `await $${keyword}('${description}')(${browserObject},${testData})\n`;
|
|
14
15
|
}
|
|
15
|
-
function testSuite(description, scenariotestBlock, options) {
|
|
16
|
-
return `\ntest.describe('${description}', () => {
|
|
16
|
+
function testSuite(description, scenariotestBlock, tags, background, options = null) {
|
|
17
|
+
return `\ntest.describe('${description}${tags.join(" ")}', () => {
|
|
18
|
+
${background}
|
|
19
|
+
\n
|
|
17
20
|
${scenariotestBlock}
|
|
18
21
|
})`;
|
|
19
22
|
}
|
|
20
|
-
function testCase(steps, examples, description, browserObjects, tags, option) {
|
|
23
|
+
function testCase(steps, examples, description, browserObjects, tags, background, option) {
|
|
21
24
|
if (examples.length >= 1) {
|
|
22
25
|
const exmapleScenario = examples.map(($ele, index) => {
|
|
23
26
|
var exampleDescription = Object.values($ele).map(val => {
|
|
24
27
|
return val.concat('-');
|
|
25
28
|
});
|
|
26
29
|
let avoidRepitationDescription = exampleDescription.join('').concat(`Example-${index + 1}`);
|
|
27
|
-
return testBlock(avoidRepitationDescription, steps, browserObjects
|
|
30
|
+
return testBlock(avoidRepitationDescription, steps, browserObjects);
|
|
28
31
|
});
|
|
29
|
-
return testSuite(description, exmapleScenario.join('\n'));
|
|
32
|
+
return testSuite(description, exmapleScenario.join('\n'), tags, background);
|
|
30
33
|
}
|
|
31
|
-
return testSuite(`${description}-title`, testBlock(description, steps, browserObjects, tags)
|
|
34
|
+
return testSuite(`${description}-title`, testBlock(description, steps, browserObjects), tags, background);
|
|
32
35
|
}
|
|
33
|
-
function testBlock(description, steps, browserObjects
|
|
34
|
-
return `\ntest("${description}
|
|
36
|
+
function testBlock(description, steps, browserObjects) {
|
|
37
|
+
return `\ntest("${description}", async({${browserObjects.join(',')}}) => {
|
|
35
38
|
${steps.join(`\n\t`)}
|
|
36
39
|
})`;
|
|
37
40
|
}
|
|
@@ -46,4 +49,9 @@ function testFile(testCase, relativeFilePath, $tags, options = null) {
|
|
|
46
49
|
\n
|
|
47
50
|
${testCase.join('')}
|
|
48
51
|
`;
|
|
52
|
+
}
|
|
53
|
+
function testBackGround(backgroundSteps, inputs) {
|
|
54
|
+
return ` test.beforeEach(async ({${inputs.join(',')}}) => { \n
|
|
55
|
+
${backgroundSteps.join(`\n`)}
|
|
56
|
+
});`;
|
|
49
57
|
}
|
|
@@ -23,7 +23,7 @@ async 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;
|
|
26
|
+
var _$scenario$scenario, _$scenario$scenario2;
|
|
27
27
|
const $currentScenario = {
|
|
28
28
|
currentArgument: '',
|
|
29
29
|
dataTableStep: '',
|
|
@@ -58,10 +58,10 @@ async function testDataCreation() {
|
|
|
58
58
|
if (typeof $scenario.background === Object) {
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
-
if ($scenario.scenario.examples.length) {
|
|
62
|
-
var _$scenario$
|
|
61
|
+
if ((_$scenario$scenario2 = $scenario.scenario) !== null && _$scenario$scenario2 !== void 0 && (_$scenario$scenario2 = _$scenario$scenario2.examples) !== null && _$scenario$scenario2 !== void 0 && _$scenario$scenario2.length) {
|
|
62
|
+
var _$scenario$scenario3;
|
|
63
63
|
exampleSteps = $scenario.scenario.steps.map(element => (0, _testStructure.extactStepArgs)(element.text).refactoredStep);
|
|
64
|
-
(_$scenario$
|
|
64
|
+
(_$scenario$scenario3 = $scenario.scenario) === null || _$scenario$scenario3 === void 0 || _$scenario$scenario3.examples.map(example => {
|
|
65
65
|
var _example$tableHeader;
|
|
66
66
|
body = example === null || example === void 0 ? void 0 : example.tableBody.map(cell => {
|
|
67
67
|
return cell === null || cell === void 0 ? void 0 : cell.cells.map(example => example.value);
|
|
@@ -9,10 +9,10 @@ var _stringManipulation = require("../utils/stringManipulation");
|
|
|
9
9
|
var _stepsnippets = require("./stepGenerate/stepsnippets");
|
|
10
10
|
function testSnippet(featureContent, featureFilePath) {
|
|
11
11
|
var currentScenarios = [];
|
|
12
|
-
|
|
12
|
+
var $tags = {};
|
|
13
13
|
featureContent.scenarios.forEach(scenario => {
|
|
14
|
-
scenario.scenarioTags = [...
|
|
15
|
-
$tags = Object.assign($tags, handleInputTags(
|
|
14
|
+
scenario.scenarioTags = [...scenario.scenarioTags, ...featureContent.featureTags];
|
|
15
|
+
$tags = Object.assign($tags, handleInputTags(scenario));
|
|
16
16
|
const _constructStep = scenarioSnippet(scenario);
|
|
17
17
|
currentScenarios.push(_constructStep);
|
|
18
18
|
});
|
|
@@ -50,7 +50,7 @@ function scenarioSnippet(scenario) {
|
|
|
50
50
|
return;
|
|
51
51
|
});
|
|
52
52
|
const pageObject = browserObjectHandle(currentInputs);
|
|
53
|
-
return (0, _stepsnippets.testCase)(currentStep, scenario === null || scenario === void 0 ? void 0 : scenario.examples, scenario === null || scenario === void 0 ? void 0 : scenario.scenariodescription, pageObject, scenario.scenarioTags);
|
|
53
|
+
return (0, _stepsnippets.testCase)(currentStep, scenario === null || scenario === void 0 ? void 0 : scenario.examples, scenario === null || scenario === void 0 ? void 0 : scenario.scenariodescription, pageObject, scenario.scenarioTags, backgroundHandle(scenario.background));
|
|
54
54
|
}
|
|
55
55
|
function browserObjectHandle(arrayofBrowserObjects) {
|
|
56
56
|
var browserinputs = [];
|
|
@@ -60,7 +60,8 @@ function browserObjectHandle(arrayofBrowserObjects) {
|
|
|
60
60
|
return (0, _stringManipulation.avoidDuplicate)(browserinputs);
|
|
61
61
|
}
|
|
62
62
|
function handleInputTags(scenario) {
|
|
63
|
-
|
|
63
|
+
var _scenario$examples;
|
|
64
|
+
if (((_scenario$examples = scenario.examples) === null || _scenario$examples === void 0 ? void 0 : _scenario$examples.length) >= 1) {
|
|
64
65
|
var _tagsObjects = {};
|
|
65
66
|
scenario.examples.forEach(($ele, index) => {
|
|
66
67
|
var exampleDescription = Object.values($ele).map(val => {
|
|
@@ -75,4 +76,19 @@ function handleInputTags(scenario) {
|
|
|
75
76
|
return {
|
|
76
77
|
[scenario.scenariodescription]: scenario.scenarioTags
|
|
77
78
|
};
|
|
79
|
+
}
|
|
80
|
+
function backgroundHandle(background) {
|
|
81
|
+
const currentBackground = [];
|
|
82
|
+
const backgroundInput = [];
|
|
83
|
+
background.forEach(b_scenario => {
|
|
84
|
+
var {
|
|
85
|
+
refactoredStep,
|
|
86
|
+
currentArgument
|
|
87
|
+
} = extactStepArgs(b_scenario.stepDescription);
|
|
88
|
+
var input = inputsParamterMap.get(`'${refactoredStep}'`);
|
|
89
|
+
backgroundInput.push(input);
|
|
90
|
+
currentBackground.push((0, _stepsnippets.testStep)(b_scenario.keyword, refactoredStep, input, currentArgument.join(',')));
|
|
91
|
+
return;
|
|
92
|
+
});
|
|
93
|
+
return (0, _stepsnippets.testBackGround)(currentBackground, browserObjectHandle(backgroundInput));
|
|
78
94
|
}
|