@zohodesk/testinglibrary 0.1.8-stb-bdd-v2 → 0.1.8-stb-bdd-v4
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.
|
@@ -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(" ")}', () => {
|
|
@@ -40,14 +42,12 @@ function testFile(testCase, relativeFilePath, $tags, backgroundScenario = " ", o
|
|
|
40
42
|
return ` // ${relativeFilePath}
|
|
41
43
|
import { test, createNativeBDD } from "${TESTING_LIBRARY}";
|
|
42
44
|
const {$Given,$When,$Then,$And} = createNativeBDD()
|
|
43
|
-
\n
|
|
44
45
|
test.use({
|
|
45
46
|
$test: ({}, use) => use(test),
|
|
46
|
-
$tags: ({}, use, testInfo) => use(${JSON.stringify($tags)}
|
|
47
|
+
$tags: ({}, use, testInfo) => use(${JSON.stringify($tags)}
|
|
48
|
+
[testInfo.titlePath.slice(2).join("|")] || [])
|
|
47
49
|
})
|
|
48
|
-
\n
|
|
49
50
|
${backgroundScenario}
|
|
50
|
-
\n
|
|
51
51
|
${testCase.join('')}
|
|
52
52
|
`;
|
|
53
53
|
}
|
|
@@ -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 = [];
|
|
@@ -106,10 +106,9 @@ function main() {
|
|
|
106
106
|
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
107
107
|
const command = playwrightPath;
|
|
108
108
|
const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? require.resolve('./setup/config-creator.js') : require.resolve('../../../playwright.config.js');
|
|
109
|
-
const args = ['test', '--config', configPath].concat(playwrightArgs);
|
|
110
109
|
let promises = [];
|
|
111
110
|
if (bddMode) {
|
|
112
|
-
(0, _bddPoc.createCucumberBDD)();
|
|
111
|
+
promises.push((0, _bddPoc.createCucumberBDD)());
|
|
113
112
|
if (userArgsObject !== null && userArgsObject !== void 0 && userArgsObject.edition || userArgsObject !== null && userArgsObject !== void 0 && userArgsObject.tags) {
|
|
114
113
|
if (userArgsObject !== null && userArgsObject !== void 0 && userArgsObject.edition) {
|
|
115
114
|
playwrightArgs.push('--grep-invert');
|
|
@@ -118,8 +117,8 @@ function main() {
|
|
|
118
117
|
}
|
|
119
118
|
playwrightArgs.push((0, _tagsHandle.allowedTags)(userArgsObject));
|
|
120
119
|
}
|
|
121
|
-
// promises.push(runPreprocessing(tagArgs, configPath));
|
|
122
120
|
}
|
|
121
|
+
const args = ['test', '--config', configPath].concat(playwrightArgs);
|
|
123
122
|
Promise.all(promises).then(() => runPlaywright(command, args)).catch(err => {
|
|
124
123
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, err);
|
|
125
124
|
process.exit();
|