@zohodesk/testinglibrary 0.1.8-exp-bdd-v5 → 0.1.8-exp-bdd-v7
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/core-runner/runner.js +5 -4
- package/build/bdd-poc/test/cucumber/featureFileParer.js +16 -14
- package/build/bdd-poc/test/cucumber/parserCucumber.js +15 -0
- package/build/bdd-poc/test/stepGenerate/extractTestInputs.js +36 -0
- package/build/bdd-poc/test/stepGenerate/stepFileGenerate.js +15 -11
- package/build/bdd-poc/test/stepGenerate/stepsnippets.js +17 -9
- package/build/bdd-poc/test/tagsHandle.js +69 -0
- package/build/bdd-poc/test/testDataMap.js +9 -10
- package/build/bdd-poc/test/testStructure.js +32 -23
- package/build/bdd-poc/utils/stringManipulation.js +7 -0
- package/build/core/playwright/builtInFixtures/index.js +4 -3
- package/build/core/playwright/tag-processor.js +4 -2
- package/build/core/playwright/test-runner.js +9 -0
- package/build/utils/fileUtils.js +20 -1
- package/build/utils/getFilePath.js +2 -1
- package/npm-shrinkwrap.json +1 -1
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -1,19 +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.stepFileMap = stepFileMap;
|
|
8
7
|
var _fastGlob = require("fast-glob");
|
|
9
|
-
var
|
|
8
|
+
var _fileUtils = require("../../utils/fileUtils");
|
|
9
|
+
var _stringManipulation = require("../utils/stringManipulation");
|
|
10
|
+
var _getFilePath = require("../../utils/getFilePath");
|
|
10
11
|
async function stepFileMap() {
|
|
11
|
-
const actualSpecPattern =
|
|
12
|
+
const actualSpecPattern = (0, _stringManipulation.filePathPattern)((0, _fileUtils.resolveFilePath)(process.cwd(), 'uat', 'modules', '**', '**', '**', '**', '**', '**', '**', '**', '*.spec.js'), _getFilePath.isWindows);
|
|
12
13
|
await (0, _fastGlob.globSync)(actualSpecPattern, {
|
|
13
14
|
dot: true,
|
|
14
15
|
cwd: process.cwd()
|
|
15
16
|
}).forEach(FilePath => {
|
|
16
|
-
const specFilePath =
|
|
17
|
+
const specFilePath = path.resolve(process.cwd(), FilePath);
|
|
17
18
|
require(specFilePath);
|
|
18
19
|
});
|
|
19
20
|
}
|
|
@@ -1,40 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.parseFeature = parseFeature;
|
|
7
|
-
var
|
|
8
|
-
var _messages = require("@cucumber/messages");
|
|
9
|
-
var uuidFn = _messages.IdGenerator.uuid();
|
|
10
|
-
var builder = new _gherkin.AstBuilder(uuidFn);
|
|
11
|
-
var matcher = new _gherkin.GherkinClassicTokenMatcher();
|
|
12
|
-
var parser = new _gherkin.Parser(builder, matcher);
|
|
8
|
+
var _parserCucumber = _interopRequireDefault(require("./parserCucumber"));
|
|
13
9
|
function parseFeature(featureFileContent) {
|
|
14
10
|
var _gherkinDocument$feat;
|
|
15
|
-
var gherkinDocument =
|
|
11
|
+
var gherkinDocument = (0, _parserCucumber.default)(featureFileContent);
|
|
16
12
|
var currentFeature = {
|
|
17
13
|
feature: "",
|
|
18
|
-
|
|
14
|
+
featureTags: [],
|
|
19
15
|
scenarios: []
|
|
20
16
|
};
|
|
17
|
+
var isBackgroundExist;
|
|
21
18
|
currentFeature.feature = gherkinDocument.feature.name;
|
|
22
|
-
currentFeature.
|
|
19
|
+
currentFeature.featureTags = (_gherkinDocument$feat = gherkinDocument.feature) === null || _gherkinDocument$feat === void 0 ? void 0 : _gherkinDocument$feat.tags.map(tag => tag.name);
|
|
23
20
|
gherkinDocument.feature.children.forEach($scenario => {
|
|
24
21
|
var _$scenario$scenario, _$scenario$scenario2, _$scenario$scenario3, _$scenario$scenario4;
|
|
25
22
|
var scenarioSteps = {
|
|
26
23
|
scenariodescription: "",
|
|
27
|
-
steps:
|
|
24
|
+
steps: [],
|
|
28
25
|
tablebody: false,
|
|
29
26
|
tableheader: false,
|
|
30
27
|
examples: [],
|
|
31
|
-
scenarioTags: []
|
|
28
|
+
scenarioTags: [],
|
|
29
|
+
background: []
|
|
32
30
|
};
|
|
33
31
|
scenarioSteps.scenariodescription = (_$scenario$scenario = $scenario.scenario) === null || _$scenario$scenario === void 0 ? void 0 : _$scenario$scenario.name;
|
|
34
32
|
if ($scenario !== null && $scenario !== void 0 && $scenario.background) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
isBackgroundExist = $scenario.background.steps.map(element => {
|
|
34
|
+
return {
|
|
35
|
+
stepDescription: element.text,
|
|
36
|
+
keyword: element.keyword
|
|
37
|
+
};
|
|
38
|
+
});
|
|
38
39
|
return;
|
|
39
40
|
}
|
|
40
41
|
(_$scenario$scenario2 = $scenario.scenario) === null || _$scenario$scenario2 === void 0 || _$scenario$scenario2.examples.map(example => {
|
|
@@ -59,6 +60,7 @@ function parseFeature(featureFileContent) {
|
|
|
59
60
|
};
|
|
60
61
|
});
|
|
61
62
|
scenarioSteps.steps = _scenarioDescription;
|
|
63
|
+
scenarioSteps.background = isBackgroundExist || [];
|
|
62
64
|
currentFeature.scenarios.push(scenarioSteps);
|
|
63
65
|
});
|
|
64
66
|
return currentFeature;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = CucumberParser;
|
|
7
|
+
var _gherkin = require("@cucumber/gherkin");
|
|
8
|
+
var _messages = require("@cucumber/messages");
|
|
9
|
+
function CucumberParser(content) {
|
|
10
|
+
var uuidFn = _messages.IdGenerator.uuid();
|
|
11
|
+
var builder = new _gherkin.AstBuilder(uuidFn);
|
|
12
|
+
var matcher = new _gherkin.GherkinClassicTokenMatcher();
|
|
13
|
+
var parser = new _gherkin.Parser(builder, matcher);
|
|
14
|
+
return parser.parse(content);
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.readStepFile = readStepFile;
|
|
8
|
+
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
9
|
+
var _stringManipulation = require("../utils/stringManipulation");
|
|
10
|
+
var _fileUtils = require("../../utils/fileUtils");
|
|
11
|
+
var _getFilePath = require("../../utils/getFilePath");
|
|
12
|
+
globalThis.inputsParamterMap = new Map();
|
|
13
|
+
async function readStepFile() {
|
|
14
|
+
const stepFilePath = (0, _stringManipulation.filePathPattern)((0, _fileUtils.resolveFilePath)(process.cwd(), 'uat', 'modules', '**', '**', '**', '**', '**', '**', '**', '**', '*.spec.js'), _getFilePath.isWindows);
|
|
15
|
+
const processedSpecFile = [];
|
|
16
|
+
return new Promise(resolve => {
|
|
17
|
+
_fastGlob.default.globSync(stepFilePath, {
|
|
18
|
+
dot: true,
|
|
19
|
+
cwd: process.cwd()
|
|
20
|
+
}).forEach(filePath => {
|
|
21
|
+
processedSpecFile.push(extractBrowserObjects(filePath));
|
|
22
|
+
});
|
|
23
|
+
Promise.all(processedSpecFile);
|
|
24
|
+
resolve(inputsParamterMap);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function extractBrowserObjects(filePath) {
|
|
28
|
+
const code = (0, _fileUtils.readFileContents)((0, _fileUtils.resolveFilePath)(process.cwd(), filePath), 'utf-8');
|
|
29
|
+
code.split('\n').forEach(step => {
|
|
30
|
+
const trimmedStep = step.trim();
|
|
31
|
+
if (trimmedStep.startsWith('Given') || trimmedStep.startsWith('When') || trimmedStep.startsWith('Then')) {
|
|
32
|
+
var sortedSpecInput = trimmedStep.split(' ').slice(1).join('').match(/\((.*?)\)/)[1].match(/\{(.*?)\}/g) || [];
|
|
33
|
+
inputsParamterMap.set(trimmedStep.replace(/"/g, `'`).match(/'(.*?)'/g).pop(), sortedSpecInput.pop());
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -5,30 +5,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.generateSpecFiles = generateSpecFiles;
|
|
8
|
-
var _fs = require("fs");
|
|
9
8
|
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
10
9
|
var _path = _interopRequireDefault(require("path"));
|
|
11
10
|
var _featureFileParer = require("../cucumber/featureFileParer");
|
|
12
11
|
var _testStructure = require("../testStructure");
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
var _fileUtils = require("../../../utils/fileUtils");
|
|
13
|
+
var _stringManipulation = require("../../utils/stringManipulation");
|
|
14
|
+
var _getFilePath = require("../../../utils/getFilePath");
|
|
15
|
+
var _extractTestInputs = require("./extractTestInputs");
|
|
16
|
+
function stepFileCreation(featureContent, stepFilename, featureFilePath) {
|
|
17
|
+
const stepsFilePath = (0, _fileUtils.resolveFilePath)(process.cwd(), 'uat', 'feature-gen', stepFilename);
|
|
15
18
|
const stepsSnippets = (0, _testStructure.testSnippet)(featureContent, featureFilePath);
|
|
16
|
-
|
|
19
|
+
(0, _fileUtils.writeFileContents)(stepsFilePath, stepsSnippets);
|
|
17
20
|
}
|
|
18
|
-
function generateSpecFiles() {
|
|
19
|
-
const featureFilePattern =
|
|
20
|
-
const generatedFolderPath =
|
|
21
|
-
if (!(0,
|
|
22
|
-
(0,
|
|
21
|
+
async function generateSpecFiles() {
|
|
22
|
+
const featureFilePattern = (0, _stringManipulation.filePathPattern)((0, _fileUtils.resolveFilePath)(process.cwd(), 'uat', 'modules', '**', '**', '**', '**', '**', '**', '**', '**', '*.feature'), _getFilePath.isWindows);
|
|
23
|
+
const generatedFolderPath = (0, _fileUtils.resolveFilePath)(process.cwd(), 'uat', 'feature-gen');
|
|
24
|
+
if (!(0, _fileUtils.checkIfFileExists)(generatedFolderPath)) {
|
|
25
|
+
(0, _fileUtils.createFolderSync)(generatedFolderPath, {
|
|
23
26
|
recursive: true
|
|
24
27
|
});
|
|
25
28
|
}
|
|
29
|
+
await (0, _extractTestInputs.readStepFile)();
|
|
26
30
|
_fastGlob.default.globSync(featureFilePattern, {
|
|
27
31
|
dot: true,
|
|
28
32
|
cwd: process.cwd()
|
|
29
33
|
}).forEach(filePath => {
|
|
30
|
-
const featurefilePath =
|
|
31
|
-
const featureContent = (0, _featureFileParer.parseFeature)((0,
|
|
34
|
+
const featurefilePath = (0, _fileUtils.resolveFilePath)(process.cwd(), filePath);
|
|
35
|
+
const featureContent = (0, _featureFileParer.parseFeature)((0, _fileUtils.readFileContents)(featurefilePath, 'utf-8'));
|
|
32
36
|
const fileName = _path.default.basename(filePath).replace('.feature', '.spec.js');
|
|
33
37
|
stepFileCreation(featureContent, fileName, filePath);
|
|
34
38
|
});
|
|
@@ -17,27 +17,35 @@ function testSuite(description, scenariotestBlock, options) {
|
|
|
17
17
|
${scenariotestBlock}
|
|
18
18
|
})`;
|
|
19
19
|
}
|
|
20
|
-
function testCase(steps, examples, description, browserObjects, option) {
|
|
21
|
-
if (examples.length) {
|
|
20
|
+
function testCase(steps, examples, description, browserObjects, tags, option) {
|
|
21
|
+
if (examples.length <= 1) {
|
|
22
22
|
const exmapleScenario = examples.map(($ele, index) => {
|
|
23
23
|
var exmapleDescription = Object.values($ele).map(val => {
|
|
24
24
|
return val.concat('-');
|
|
25
25
|
});
|
|
26
|
-
return testBlock(exmapleDescription.join('').concat(`Example-${index + 1}`), steps, browserObjects);
|
|
26
|
+
return testBlock(exmapleDescription.join('').concat(`Example-${index + 1}`), steps, browserObjects, tags);
|
|
27
27
|
});
|
|
28
28
|
return testSuite(description, exmapleScenario.join('\n'));
|
|
29
29
|
}
|
|
30
|
-
return testBlock(description, steps, browserObjects);
|
|
30
|
+
return testSuite(`${description}-title`, testBlock(description, steps, browserObjects, tags));
|
|
31
31
|
}
|
|
32
|
-
function testBlock(description, steps, browserObjects) {
|
|
33
|
-
return `\ntest("${description}", async({${browserObjects.join(',')}}) => {
|
|
32
|
+
function testBlock(description, steps, browserObjects, tags) {
|
|
33
|
+
return `\ntest("${description} ${tags.join(" ")}", async({${browserObjects.join(',')}}) => {
|
|
34
34
|
${steps.join(`\n\t`)}
|
|
35
35
|
})`;
|
|
36
36
|
}
|
|
37
|
-
function testFile(testCase, relativeFilePath) {
|
|
37
|
+
function testFile(testCase, relativeFilePath, tags, options = null) {
|
|
38
38
|
return ` // ${relativeFilePath}
|
|
39
|
-
import {test, createNativeBDD} from "${TESTING_LIBRARY}";
|
|
39
|
+
import { test, createNativeBDD } from "${TESTING_LIBRARY}";
|
|
40
40
|
const {$Given,$When,$Then,$And} = createNativeBDD()
|
|
41
41
|
${testCase.join('')}
|
|
42
42
|
`;
|
|
43
|
-
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// test.use({
|
|
46
|
+
// $test: ({}, use) => use(test),
|
|
47
|
+
// $tags: ({}, use, testInfo) => use({
|
|
48
|
+
// "Clear searched results in setup left panel @edition_agent": ["@edition_agent"],
|
|
49
|
+
// "get started link":[]
|
|
50
|
+
// }[testInfo.titlePath.slice(2).join("|")] || []),
|
|
51
|
+
// });
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.allowedTags = allowedTags;
|
|
7
|
+
exports.expressionHandle = expressionHandle;
|
|
8
|
+
var _tagProcessor = require("../../core/playwright/tag-processor");
|
|
9
|
+
const editionOrder = ['Free', 'Express', 'Standard', 'Professional', 'Enterprise'];
|
|
10
|
+
function allowedTags(userArgs) {
|
|
11
|
+
let tags = userArgs['tags'] || null;
|
|
12
|
+
if (tags !== null) {
|
|
13
|
+
if (Array.isArray(tags)) {
|
|
14
|
+
return buildGrepTags(tags, '|');
|
|
15
|
+
}
|
|
16
|
+
return tags;
|
|
17
|
+
}
|
|
18
|
+
let edition = userArgs['edition'] || null;
|
|
19
|
+
if (edition !== null) {
|
|
20
|
+
const editionFrmCli = edition.split(',');
|
|
21
|
+
if (editionFrmCli.length === 1) {
|
|
22
|
+
// const sortedEdition = editionPreprocessing(editionOrder,editionFrmCli)
|
|
23
|
+
return (0, _tagProcessor.buildEditionTags)(expressionHandle(editionFrmCli, editionOrder), '|');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
function buildGrepTags(tags, operator) {
|
|
29
|
+
return tags.join(`${operator}`);
|
|
30
|
+
}
|
|
31
|
+
function expressionHandle(editionFrmCli, editionOrder) {
|
|
32
|
+
var expression;
|
|
33
|
+
var $edition;
|
|
34
|
+
if (editionFrmCli.split('=').length !== 1) {
|
|
35
|
+
expression = editionFrmCli.split('').slice(0, 2).join('');
|
|
36
|
+
$edition = editionFrmCli.split('=').pop();
|
|
37
|
+
} else if (editionFrmCli.split('>').length !== 1) {
|
|
38
|
+
expression = editionFrmCli.split('').slice(0, 1).join('');
|
|
39
|
+
$edition = editionFrmCli.split('>').pop();
|
|
40
|
+
} else {
|
|
41
|
+
expression = editionFrmCli.split('').slice(0, 1).join('');
|
|
42
|
+
$edition = editionFrmCli.split('<').pop();
|
|
43
|
+
}
|
|
44
|
+
const index_Edition = editionOrder.indexOf($edition);
|
|
45
|
+
switch (expression) {
|
|
46
|
+
case '>=':
|
|
47
|
+
if ($edition == editionOrder[editionOrder.length - 1]) {
|
|
48
|
+
return editionOrder[editionOrder.length - 1];
|
|
49
|
+
}
|
|
50
|
+
return editionOrder.slice(0, index_Edition);
|
|
51
|
+
case '<=':
|
|
52
|
+
if ($edition == editionOrder[0]) {
|
|
53
|
+
return editionOrder.slice(1, editionOrder.length + 1);
|
|
54
|
+
}
|
|
55
|
+
return editionOrder.slice(index_Edition + 1, editionOrder.length + 1);
|
|
56
|
+
case '<':
|
|
57
|
+
if ($edition == editionOrder[0]) {
|
|
58
|
+
return editionOrder;
|
|
59
|
+
}
|
|
60
|
+
return editionOrder.slice(index_Edition, editionOrder.length + 1);
|
|
61
|
+
case '>':
|
|
62
|
+
if ($edition == editionOrder[editionOrder.length - 1]) {
|
|
63
|
+
return editionOrder;
|
|
64
|
+
}
|
|
65
|
+
return editionOrder.slice(0, index_Edition + 1);
|
|
66
|
+
default:
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -5,26 +5,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.testDataCreation = testDataCreation;
|
|
8
|
-
var _gherkin = require("@cucumber/gherkin");
|
|
9
|
-
var _messages = require("@cucumber/messages");
|
|
10
8
|
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
11
|
-
var _fs = require("fs");
|
|
12
|
-
var _path = _interopRequireDefault(require("path"));
|
|
13
9
|
var _testStructure = require("./testStructure");
|
|
10
|
+
var _fileUtils = require("../../utils/fileUtils");
|
|
11
|
+
var _parserCucumber = _interopRequireDefault(require("./cucumber/parserCucumber"));
|
|
12
|
+
var _stringManipulation = require("../utils/stringManipulation");
|
|
13
|
+
var _getFilePath = require("../../utils/getFilePath");
|
|
14
14
|
async function testDataCreation() {
|
|
15
|
-
var uuidFn = _messages.IdGenerator.uuid();
|
|
16
|
-
var builder = new _gherkin.AstBuilder(uuidFn);
|
|
17
|
-
var matcher = new _gherkin.GherkinClassicTokenMatcher();
|
|
18
|
-
var parser = new _gherkin.Parser(builder, matcher);
|
|
19
15
|
var exampleSteps = [];
|
|
20
16
|
const globalTestdata = new Map();
|
|
21
|
-
const actualStepFilePath =
|
|
17
|
+
const actualStepFilePath = (0, _stringManipulation.filePathPattern)((0, _fileUtils.resolveFilePath)('uat', 'modules', '**', '**', '**', '**', '**', '*.feature'), _getFilePath.isWindows);
|
|
22
18
|
await _fastGlob.default.globSync(actualStepFilePath, {
|
|
23
19
|
dot: true,
|
|
24
20
|
cwd: process.cwd()
|
|
25
21
|
}).forEach(filePath => {
|
|
26
22
|
var body, header;
|
|
27
|
-
var gherkinDocument =
|
|
23
|
+
var gherkinDocument = (0, _parserCucumber.default)((0, _fileUtils.readFileContents)((0, _fileUtils.resolveFilePath)(process.cwd(), filePath), 'utf-8'));
|
|
28
24
|
gherkinDocument.feature.children.forEach($scenario => {
|
|
29
25
|
var _$scenario$scenario;
|
|
30
26
|
const $currentScenario = {
|
|
@@ -58,6 +54,9 @@ async function testDataCreation() {
|
|
|
58
54
|
}
|
|
59
55
|
globalTestdata.set(refactoredStep, Object.assign({}, $currentScenario));
|
|
60
56
|
});
|
|
57
|
+
if (typeof $scenario.background === Object) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
61
60
|
if ($scenario.scenario.examples.length) {
|
|
62
61
|
var _$scenario$scenario2;
|
|
63
62
|
exampleSteps = $scenario.scenario.steps.map(element => (0, _testStructure.extactStepArgs)(element.text).refactoredStep);
|
|
@@ -1,20 +1,17 @@
|
|
|
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.extactStepArgs = extactStepArgs;
|
|
8
7
|
exports.testSnippet = testSnippet;
|
|
9
|
-
var _path = _interopRequireDefault(require("path"));
|
|
10
|
-
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
11
|
-
var _fs = require("fs");
|
|
12
8
|
var _stringManipulation = require("../utils/stringManipulation");
|
|
13
9
|
var _stepsnippets = require("./stepGenerate/stepsnippets");
|
|
14
|
-
const inputsParamterMap = new Map();
|
|
15
10
|
function testSnippet(featureContent, featureFilePath) {
|
|
16
11
|
var currentScenarios = [];
|
|
17
12
|
featureContent.scenarios.forEach(scenario => {
|
|
13
|
+
scenario.scenarioTags = featureContent.featureTags || [];
|
|
14
|
+
// const $tags = tagsAsInput(featureContent)
|
|
18
15
|
const _constructStep = scenarioSnippet(scenario);
|
|
19
16
|
currentScenarios.push(_constructStep);
|
|
20
17
|
});
|
|
@@ -52,23 +49,23 @@ function scenarioSnippet(scenario) {
|
|
|
52
49
|
return;
|
|
53
50
|
});
|
|
54
51
|
const pageObject = browserObjectHandle(currentInputs);
|
|
55
|
-
return (0, _stepsnippets.testCase)(currentStep, scenario === null || scenario === void 0 ? void 0 : scenario.examples, scenario === null || scenario === void 0 ? void 0 : scenario.scenariodescription, pageObject);
|
|
52
|
+
return (0, _stepsnippets.testCase)(currentStep, scenario === null || scenario === void 0 ? void 0 : scenario.examples, scenario === null || scenario === void 0 ? void 0 : scenario.scenariodescription, scenario.scenarioTags, pageObject, scenario.scenarioTags);
|
|
56
53
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var sortedSpecInput = trimmedStep.split(' ').slice(1).join('').match(/\((.*?)\)/)[1].match(/\{(.*?)\}/g) || [];
|
|
68
|
-
inputsParamterMap.set(trimmedStep.match(/'(.*?)'/g).pop(), sortedSpecInput.pop());
|
|
69
|
-
}
|
|
54
|
+
function tagsAsInput(scenario) {
|
|
55
|
+
if (scenario.examples.length >= 1) {
|
|
56
|
+
var tagsInput = {};
|
|
57
|
+
return scenario.examples.map(($ele, index) => {
|
|
58
|
+
var exampleDescription = Object.values($ele).map(val => {
|
|
59
|
+
return val.concat('-');
|
|
60
|
+
});
|
|
61
|
+
return Object.assign(tagsInput, {
|
|
62
|
+
[exampleDescription.join('').concat(`Example-${index + 1}`)]: scenario.scenarioTags
|
|
63
|
+
});
|
|
70
64
|
});
|
|
71
|
-
}
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
[scenario.scenariodescription]: scenario.scenarioTags
|
|
68
|
+
};
|
|
72
69
|
}
|
|
73
70
|
function browserObjectHandle(arrayofBrowserObjects) {
|
|
74
71
|
var browserinputs = [];
|
|
@@ -77,6 +74,18 @@ function browserObjectHandle(arrayofBrowserObjects) {
|
|
|
77
74
|
});
|
|
78
75
|
return (0, _stringManipulation.avoidDuplicate)(browserinputs);
|
|
79
76
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
|
|
78
|
+
// function handleInputTags(scenario){
|
|
79
|
+
// if(scenario.examples.length >= 1){
|
|
80
|
+
// var obj = {}
|
|
81
|
+
// scenario.examples.forEach(($ele, index) => {
|
|
82
|
+
// var exampleDescription = Object.values($ele).map((val) => {
|
|
83
|
+
// return val.concat('-');
|
|
84
|
+
// });
|
|
85
|
+
// Object.assign(obj,{ [exampleDescription.join('').concat(`Example-${index + 1}`)]: scenario.scenarioTags })
|
|
86
|
+
|
|
87
|
+
// });
|
|
88
|
+
// return obj
|
|
89
|
+
// }
|
|
90
|
+
// return { [scenario.scenariodescription] : scenario.scenarioTags };
|
|
91
|
+
// }
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.avoidDuplicate = avoidDuplicate;
|
|
7
|
+
exports.filePathPattern = filePathPattern;
|
|
7
8
|
exports.removeAll = removeAll;
|
|
8
9
|
function removeAll(InputString, toRemove, regex = undefined, options = null) {
|
|
9
10
|
if (regex) {
|
|
@@ -16,4 +17,10 @@ function removeAll(InputString, toRemove, regex = undefined, options = null) {
|
|
|
16
17
|
}
|
|
17
18
|
function avoidDuplicate(arrayOfInputs) {
|
|
18
19
|
return [...new Set(arrayOfInputs)];
|
|
20
|
+
}
|
|
21
|
+
function filePathPattern(filePath, isWindows = true) {
|
|
22
|
+
if (isWindows) {
|
|
23
|
+
return filePath.replace('\\', '/');
|
|
24
|
+
}
|
|
25
|
+
return filePath;
|
|
19
26
|
}
|
|
@@ -8,7 +8,8 @@ exports.default = void 0;
|
|
|
8
8
|
var _page = _interopRequireDefault(require("./page"));
|
|
9
9
|
var _context = _interopRequireDefault(require("./context"));
|
|
10
10
|
var _cacheLayer = _interopRequireDefault(require("./cacheLayer"));
|
|
11
|
-
|
|
11
|
+
// import addTags from './addTags';
|
|
12
|
+
|
|
12
13
|
function getBuiltInFixtures(bddMode) {
|
|
13
14
|
let builtInFixtures = {
|
|
14
15
|
..._page.default,
|
|
@@ -17,8 +18,8 @@ function getBuiltInFixtures(bddMode) {
|
|
|
17
18
|
};
|
|
18
19
|
if (bddMode) {
|
|
19
20
|
builtInFixtures = {
|
|
20
|
-
...builtInFixtures
|
|
21
|
-
...
|
|
21
|
+
...builtInFixtures
|
|
22
|
+
// ...addTags
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
return builtInFixtures;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.buildEditionTags = buildEditionTags;
|
|
7
|
+
exports.editionPreprocessing = editionPreprocessing;
|
|
6
8
|
exports.tagProcessor = tagProcessor;
|
|
7
9
|
var _logger = require("../../utils/logger");
|
|
8
10
|
/* eslint-disable dot-notation */
|
|
@@ -28,11 +30,11 @@ function editionPreprocessing(editionOrder, selectedEdition) {
|
|
|
28
30
|
if (index !== -1) {
|
|
29
31
|
let resultArray;
|
|
30
32
|
if (operator === '<=') {
|
|
31
|
-
resultArray = editionOrder.slice(index + 1);
|
|
33
|
+
resultArray = editionOrder.slice(0, index + 1);
|
|
32
34
|
} else if (operator === '>=') {
|
|
33
35
|
resultArray = editionOrder.slice(0, index);
|
|
34
36
|
} else if (operator === '<') {
|
|
35
|
-
resultArray = editionOrder.slice(index);
|
|
37
|
+
resultArray = editionOrder.slice(0, index);
|
|
36
38
|
} else if (operator === '>') {
|
|
37
39
|
resultArray = editionOrder.slice(0, index + 1);
|
|
38
40
|
} else {
|
|
@@ -15,6 +15,7 @@ var _readConfigFile = require("./readConfigFile");
|
|
|
15
15
|
var _rootPath = require("../../utils/rootPath");
|
|
16
16
|
var _tagProcessor = require("./tag-processor");
|
|
17
17
|
var _bddPoc = require("../../bdd-poc");
|
|
18
|
+
var _tagsHandle = require("../../bdd-poc/test/tagsHandle");
|
|
18
19
|
function parseUserArgs() {
|
|
19
20
|
return (0, _cliArgsToObject.cliArgsToObject)(process.argv.slice(2));
|
|
20
21
|
}
|
|
@@ -109,6 +110,14 @@ function main() {
|
|
|
109
110
|
let promises = [];
|
|
110
111
|
if (bddMode) {
|
|
111
112
|
(0, _bddPoc.createCucumberBDD)();
|
|
113
|
+
if (userArgsObject['edition'] || userArgsObject['tags']) {
|
|
114
|
+
if (userArgsObject['edition']) {
|
|
115
|
+
playwrightArgs.push('--grep-invert');
|
|
116
|
+
} else {
|
|
117
|
+
playwrightArgs.push('--grep');
|
|
118
|
+
}
|
|
119
|
+
playwrightArgs.push((0, _tagsHandle.allowedTags)(userArgsObject));
|
|
120
|
+
}
|
|
112
121
|
// promises.push(runPreprocessing(tagArgs, configPath));
|
|
113
122
|
}
|
|
114
123
|
Promise.all(promises).then(() => runPlaywright(command, args)).catch(err => {
|
package/build/utils/fileUtils.js
CHANGED
|
@@ -5,12 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.checkIfFileExists = checkIfFileExists;
|
|
8
|
+
exports.createFolderSync = createFolderSync;
|
|
8
9
|
exports.deleteFile = deleteFile;
|
|
9
10
|
exports.deleteFolder = deleteFolder;
|
|
10
11
|
exports.readFileContents = readFileContents;
|
|
12
|
+
exports.resolveFilePath = resolveFilePath;
|
|
11
13
|
exports.writeFileContents = writeFileContents;
|
|
12
|
-
var _fs =
|
|
14
|
+
var _fs = _interopRequireWildcard(require("fs"));
|
|
13
15
|
var _path = _interopRequireDefault(require("path"));
|
|
16
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
18
|
function checkIfFileExists(file) {
|
|
15
19
|
try {
|
|
16
20
|
_fs.default.accessSync(file, _fs.default.constants.F_OK);
|
|
@@ -61,4 +65,19 @@ function deleteFolder(folderPath) {
|
|
|
61
65
|
throw new Error(`Error while deleting the test data file: ${folderPath}`);
|
|
62
66
|
}
|
|
63
67
|
}
|
|
68
|
+
}
|
|
69
|
+
function resolveFilePath(...filePath) {
|
|
70
|
+
var resolvedPath;
|
|
71
|
+
for (let i = 0; i < filePath.length; i++) {
|
|
72
|
+
resolvedPath = _path.default.resolve(resolvedPath, filePath[i]);
|
|
73
|
+
}
|
|
74
|
+
return resolvedPath;
|
|
75
|
+
}
|
|
76
|
+
function createFolderSync(folderPath, options = {}) {
|
|
77
|
+
if ((0, _fs.existsSync)(folderPath)) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return (0, _fs.mkdirSync)(folderPath, {
|
|
81
|
+
recursive: true
|
|
82
|
+
});
|
|
64
83
|
}
|
|
@@ -4,8 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = getFilePathWithExtension;
|
|
7
|
+
exports.isWindows = void 0;
|
|
7
8
|
var _os = require("os");
|
|
8
|
-
const isWindows = (0, _os.platform)().toLowerCase() === 'win32';
|
|
9
|
+
const isWindows = exports.isWindows = (0, _os.platform)().toLowerCase() === 'win32';
|
|
9
10
|
function getFilePathWithExtension(binName) {
|
|
10
11
|
return isWindows ? `${binName}.cmd` : binName;
|
|
11
12
|
}
|
package/npm-shrinkwrap.json
CHANGED