@zohodesk/testinglibrary 0.1.8-stb-bdd-v4 → 0.1.8-stb-bdd-v1
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.
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.getFeatureFilePath = getFeatureFilePath;
|
|
8
7
|
exports.getStepFilePath = getStepFilePath;
|
|
9
|
-
var _readConfigFile = require("
|
|
8
|
+
var _readConfigFile = require("../../../core/playwright/readConfigFile");
|
|
10
9
|
var _getFilePath = require("../../utils/getFilePath");
|
|
11
10
|
var _stringManipulation = require("../utils/stringManipulation");
|
|
12
|
-
var _path = _interopRequireDefault(require("path"));
|
|
13
11
|
const {
|
|
14
12
|
featureFilesFolder,
|
|
15
13
|
stepDefinitionsFolder
|
|
16
14
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
17
15
|
function getFeatureFilePath() {
|
|
18
|
-
return (0, _stringManipulation.filePathPattern)(
|
|
16
|
+
return (0, _stringManipulation.filePathPattern)(path.resolve(process.cwd(), 'uat', 'modules', '**', '**', featureFilesFolder, '**', '**', '**', '**', '**', '*.feature'), _getFilePath.isWindows);
|
|
19
17
|
}
|
|
20
18
|
function getStepFilePath() {
|
|
21
|
-
return (0, _stringManipulation.filePathPattern)(
|
|
19
|
+
return (0, _stringManipulation.filePathPattern)(path.resolve(process.cwd(), 'uat', 'modules', '**', '**', stepDefinitionsFolder, '**', '**', '**', '**', '**', '*.spec.js'), _getFilePath.isWindows);
|
|
22
20
|
}
|
|
@@ -11,9 +11,7 @@ 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 `
|
|
15
|
-
await $${keyword}('${description}')(${browserObject},${testData})
|
|
16
|
-
})`;
|
|
14
|
+
return `await $${keyword}('${description}')(${browserObject},${testData})\n`;
|
|
17
15
|
}
|
|
18
16
|
function testSuite(description, scenariotestBlock, tags, options = null) {
|
|
19
17
|
return `\ntest.describe('${description}${tags.join(" ")}', () => {
|
|
@@ -42,12 +40,14 @@ function testFile(testCase, relativeFilePath, $tags, backgroundScenario = " ", o
|
|
|
42
40
|
return ` // ${relativeFilePath}
|
|
43
41
|
import { test, createNativeBDD } from "${TESTING_LIBRARY}";
|
|
44
42
|
const {$Given,$When,$Then,$And} = createNativeBDD()
|
|
43
|
+
\n
|
|
45
44
|
test.use({
|
|
46
45
|
$test: ({}, use) => use(test),
|
|
47
|
-
$tags: ({}, use, testInfo) => use(${JSON.stringify($tags)}
|
|
48
|
-
[testInfo.titlePath.slice(2).join("|")] || [])
|
|
46
|
+
$tags: ({}, use, testInfo) => use(${JSON.stringify($tags)} \n [testInfo.titlePath.slice(2).join("|")] || [])
|
|
49
47
|
})
|
|
48
|
+
\n
|
|
50
49
|
${backgroundScenario}
|
|
50
|
+
\n
|
|
51
51
|
${testCase.join('')}
|
|
52
52
|
`;
|
|
53
53
|
}
|
|
@@ -8,6 +8,7 @@ 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;
|
|
11
12
|
var currentScenarios = [];
|
|
12
13
|
var $tags = {};
|
|
13
14
|
featureContent.scenarios.forEach(scenario => {
|
|
@@ -16,9 +17,9 @@ function testSnippet(featureContent, featureFilePath) {
|
|
|
16
17
|
const _constructStep = scenarioSnippet(scenario);
|
|
17
18
|
currentScenarios.push(_constructStep);
|
|
18
19
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
if ((_featureContent$featu = featureContent.featureBackGround) !== null && _featureContent$featu !== void 0 && _featureContent$featu.length) {
|
|
21
|
+
return (0, _stepsnippets.testFile)(currentScenarios, featureFilePath, $tags, backgroundHandle(featureContent.featureBackGround));
|
|
22
|
+
}
|
|
22
23
|
return (0, _stepsnippets.testFile)(currentScenarios, featureFilePath, $tags);
|
|
23
24
|
}
|
|
24
25
|
function extactStepArgs(step) {
|
|
@@ -40,13 +41,8 @@ function extactStepArgs(step) {
|
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
43
|
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
|
-
}
|
|
50
46
|
scenario.steps.forEach(step => {
|
|
51
47
|
var {
|
|
52
48
|
refactoredStep,
|
|
@@ -85,20 +81,6 @@ function handleInputTags(scenario) {
|
|
|
85
81
|
[scenario.scenariodescription]: scenario.scenarioTags
|
|
86
82
|
};
|
|
87
83
|
}
|
|
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
84
|
function backgroundHandle(background) {
|
|
103
85
|
const currentBackground = [];
|
|
104
86
|
const backgroundInput = [];
|
|
@@ -106,9 +106,10 @@ 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);
|
|
109
110
|
let promises = [];
|
|
110
111
|
if (bddMode) {
|
|
111
|
-
|
|
112
|
+
(0, _bddPoc.createCucumberBDD)();
|
|
112
113
|
if (userArgsObject !== null && userArgsObject !== void 0 && userArgsObject.edition || userArgsObject !== null && userArgsObject !== void 0 && userArgsObject.tags) {
|
|
113
114
|
if (userArgsObject !== null && userArgsObject !== void 0 && userArgsObject.edition) {
|
|
114
115
|
playwrightArgs.push('--grep-invert');
|
|
@@ -117,8 +118,8 @@ function main() {
|
|
|
117
118
|
}
|
|
118
119
|
playwrightArgs.push((0, _tagsHandle.allowedTags)(userArgsObject));
|
|
119
120
|
}
|
|
121
|
+
// promises.push(runPreprocessing(tagArgs, configPath));
|
|
120
122
|
}
|
|
121
|
-
const args = ['test', '--config', configPath].concat(playwrightArgs);
|
|
122
123
|
Promise.all(promises).then(() => runPlaywright(command, args)).catch(err => {
|
|
123
124
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, err);
|
|
124
125
|
process.exit();
|