@zohodesk/testinglibrary 0.1.8-exp-bdd-v9 → 0.1.8-exp-bdd-v10
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/bin/cli.js +1 -1
- package/build/bdd-poc/test/stepGenerate/stepsnippets.js +9 -8
- package/build/bdd-poc/test/tagsHandle.js +2 -2
- package/build/bdd-poc/test/testStructure.js +8 -4
- package/build/core/playwright/builtInFixtures/addTags.js +1 -1
- package/build/core/playwright/test-runner.js +2 -2
- package/npm-shrinkwrap.json +1 -1
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -13,14 +13,12 @@ const TESTING_LIBRARY = exports.TESTING_LIBRARY = '@zohodesk/testinglibrary';
|
|
|
13
13
|
function testStep(keyword, description, browserObject, testData, options) {
|
|
14
14
|
return `await $${keyword}('${description}')(${browserObject},${testData})\n`;
|
|
15
15
|
}
|
|
16
|
-
function testSuite(description, scenariotestBlock, tags,
|
|
16
|
+
function testSuite(description, scenariotestBlock, tags, options = null) {
|
|
17
17
|
return `\ntest.describe('${description}${tags.join(" ")}', () => {
|
|
18
|
-
${background}
|
|
19
|
-
\n
|
|
20
18
|
${scenariotestBlock}
|
|
21
19
|
})`;
|
|
22
20
|
}
|
|
23
|
-
function testCase(steps, examples, description, browserObjects, tags,
|
|
21
|
+
function testCase(steps, examples, description, browserObjects, tags, option) {
|
|
24
22
|
if (examples.length >= 1) {
|
|
25
23
|
const exmapleScenario = examples.map(($ele, index) => {
|
|
26
24
|
var exampleDescription = Object.values($ele).map(val => {
|
|
@@ -29,16 +27,16 @@ function testCase(steps, examples, description, browserObjects, tags, background
|
|
|
29
27
|
let avoidRepitationDescription = exampleDescription.join('').concat(`Example-${index + 1}`);
|
|
30
28
|
return testBlock(avoidRepitationDescription, steps, browserObjects);
|
|
31
29
|
});
|
|
32
|
-
return testSuite(description, exmapleScenario.join('\n'), tags
|
|
30
|
+
return testSuite(description, exmapleScenario.join('\n'), tags);
|
|
33
31
|
}
|
|
34
|
-
return testSuite(`${description}-title`, testBlock(description, steps, browserObjects), tags
|
|
32
|
+
return testSuite(`${description}-title`, testBlock(description, steps, browserObjects), tags);
|
|
35
33
|
}
|
|
36
34
|
function testBlock(description, steps, browserObjects) {
|
|
37
35
|
return `\ntest("${description}", async({${browserObjects.join(',')}}) => {
|
|
38
36
|
${steps.join(`\n\t`)}
|
|
39
37
|
})`;
|
|
40
38
|
}
|
|
41
|
-
function testFile(testCase, relativeFilePath, $tags, options = null) {
|
|
39
|
+
function testFile(testCase, relativeFilePath, $tags, backgroundScenario = " ", options = null) {
|
|
42
40
|
return ` // ${relativeFilePath}
|
|
43
41
|
import { test, createNativeBDD } from "${TESTING_LIBRARY}";
|
|
44
42
|
const {$Given,$When,$Then,$And} = createNativeBDD()
|
|
@@ -46,7 +44,10 @@ function testFile(testCase, relativeFilePath, $tags, options = null) {
|
|
|
46
44
|
test.use({
|
|
47
45
|
$test: ({}, use) => use(test),
|
|
48
46
|
$tags: ({}, use, testInfo) => use(${JSON.stringify($tags)} \n [testInfo.titlePath.slice(2).join("|")] || [])
|
|
49
|
-
|
|
47
|
+
})
|
|
48
|
+
\n
|
|
49
|
+
${backgroundScenario}
|
|
50
|
+
\n
|
|
50
51
|
${testCase.join('')}
|
|
51
52
|
`;
|
|
52
53
|
}
|
|
@@ -8,14 +8,14 @@ exports.expressionHandle = expressionHandle;
|
|
|
8
8
|
var _tagProcessor = require("../../core/playwright/tag-processor");
|
|
9
9
|
const editionOrder = ['Free', 'Express', 'Standard', 'Professional', 'Enterprise'];
|
|
10
10
|
function allowedTags(userArgs) {
|
|
11
|
-
let tags = userArgs
|
|
11
|
+
let tags = (userArgs === null || userArgs === void 0 ? void 0 : userArgs.tags) || null;
|
|
12
12
|
if (tags !== null) {
|
|
13
13
|
if (Array.isArray(tags)) {
|
|
14
14
|
return buildGrepTags(tags, '|');
|
|
15
15
|
}
|
|
16
16
|
return tags;
|
|
17
17
|
}
|
|
18
|
-
let edition = userArgs
|
|
18
|
+
let edition = (userArgs === null || userArgs === void 0 ? void 0 : userArgs.edition) || null;
|
|
19
19
|
if (edition !== null) {
|
|
20
20
|
const editionFrmCli = edition.split(',');
|
|
21
21
|
if (editionFrmCli.length === 1) {
|
|
@@ -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,6 +17,9 @@ function testSnippet(featureContent, featureFilePath) {
|
|
|
16
17
|
const _constructStep = scenarioSnippet(scenario);
|
|
17
18
|
currentScenarios.push(_constructStep);
|
|
18
19
|
});
|
|
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
|
+
}
|
|
19
23
|
return (0, _stepsnippets.testFile)(currentScenarios, featureFilePath, $tags);
|
|
20
24
|
}
|
|
21
25
|
function extactStepArgs(step) {
|
|
@@ -50,14 +54,14 @@ function scenarioSnippet(scenario) {
|
|
|
50
54
|
return;
|
|
51
55
|
});
|
|
52
56
|
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
|
|
57
|
+
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);
|
|
54
58
|
}
|
|
55
59
|
function browserObjectHandle(arrayofBrowserObjects) {
|
|
56
|
-
var
|
|
60
|
+
var browserInputs = [];
|
|
57
61
|
arrayofBrowserObjects.forEach(pageObject => {
|
|
58
|
-
browserinputs = [...
|
|
62
|
+
browserinputs = [...browserInputs, ...(0, _stringManipulation.removeAll)(pageObject, ['{', '}']).split(',')];
|
|
59
63
|
});
|
|
60
|
-
return (0, _stringManipulation.avoidDuplicate)(
|
|
64
|
+
return (0, _stringManipulation.avoidDuplicate)(browserInputs);
|
|
61
65
|
}
|
|
62
66
|
function handleInputTags(scenario) {
|
|
63
67
|
var _scenario$examples;
|
|
@@ -110,8 +110,8 @@ function main() {
|
|
|
110
110
|
let promises = [];
|
|
111
111
|
if (bddMode) {
|
|
112
112
|
(0, _bddPoc.createCucumberBDD)();
|
|
113
|
-
if (userArgsObject
|
|
114
|
-
if (userArgsObject
|
|
113
|
+
if (userArgsObject !== null && userArgsObject !== void 0 && userArgsObject.edition || userArgsObject !== null && userArgsObject !== void 0 && userArgsObject.tags) {
|
|
114
|
+
if (userArgsObject !== null && userArgsObject !== void 0 && userArgsObject.edition) {
|
|
115
115
|
playwrightArgs.push('--grep-invert');
|
|
116
116
|
} else {
|
|
117
117
|
playwrightArgs.push('--grep');
|
package/npm-shrinkwrap.json
CHANGED