@zohodesk/testinglibrary 0.1.8-stb-bdd-v4 → 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.
|
@@ -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,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
|
+
// }
|
|
@@ -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'),
|