@zohodesk/testinglibrary 0.1.8-exp.4 → 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.
- package/.babelrc +18 -18
- package/.eslintrc.js +31 -31
- package/.prettierrc +5 -5
- package/README.md +17 -17
- package/bin/cli.js +2 -2
- package/build/bdd-framework/cli/commands/env.js +3 -3
- package/build/bdd-framework/cli/options.js +4 -4
- package/build/bdd-framework/cli/worker.js +3 -3
- package/build/bdd-framework/config/dir.js +6 -6
- package/build/bdd-framework/config/env.js +3 -3
- package/build/bdd-framework/config/index.js +2 -2
- package/build/bdd-framework/config/lang.js +2 -2
- package/build/bdd-framework/cucumber/buildStepDefinition.js +3 -3
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +3 -3
- package/build/bdd-framework/cucumber/loadSources.js +9 -9
- package/build/bdd-framework/gen/fixtures.js +8 -8
- package/build/bdd-framework/gen/formatter.js +7 -7
- package/build/bdd-framework/gen/i18n.js +3 -3
- package/build/bdd-framework/gen/index.js +2 -2
- package/build/bdd-framework/gen/testFile.js +16 -16
- package/build/bdd-framework/gen/testNode.js +3 -3
- package/build/bdd-framework/gen/testPoms.js +31 -31
- package/build/bdd-framework/hooks/scenario.js +6 -6
- package/build/bdd-framework/hooks/worker.js +4 -4
- package/build/bdd-framework/playwright/fixtureParameterNames.js +3 -3
- package/build/bdd-framework/playwright/getLocationInFile.js +4 -4
- package/build/bdd-framework/playwright/loadConfig.js +3 -3
- package/build/bdd-framework/playwright/testTypeImpl.js +11 -11
- package/build/bdd-framework/playwright/transform.js +4 -4
- package/build/bdd-framework/playwright/utils.js +2 -2
- package/build/bdd-framework/run/StepInvoker.js +2 -2
- package/build/bdd-framework/run/bddWorld.js +15 -15
- package/build/bdd-framework/snippets/index.js +2 -2
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +4 -4
- package/build/bdd-framework/stepDefinitions/createBdd.js +2 -2
- package/build/bdd-framework/stepDefinitions/decorators/class.js +7 -7
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +6 -6
- package/build/bdd-framework/stepDefinitions/defineStep.js +3 -3
- package/build/bdd-framework/stepDefinitions/stepConfig.js +5 -5
- package/build/bdd-framework/utils/exit.js +18 -22
- package/build/bdd-framework/utils/index.js +9 -9
- package/build/bdd-framework/utils/jsStringWrap.js +9 -9
- package/build/bdd-framework/utils/logger.js +2 -2
- package/build/bdd-poc/config/pathConfig.js +20 -0
- package/build/bdd-poc/core-runner/exportMethods.js +20 -0
- package/build/bdd-poc/core-runner/main.js +10 -0
- package/build/bdd-poc/core-runner/runner.js +20 -0
- package/build/bdd-poc/core-runner/stepDefinitions.js +52 -0
- package/build/bdd-poc/index.js +26 -0
- package/build/bdd-poc/test/cucumber/featureFileParer.js +84 -0
- 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 +38 -0
- package/build/bdd-poc/test/stepGenerate/stepsnippets.js +58 -0
- package/build/bdd-poc/test/tagsHandle.js +69 -0
- package/build/bdd-poc/test/testDataMap.js +97 -0
- package/build/bdd-poc/test/testStructure.js +98 -0
- package/build/bdd-poc/utils/stringManipulation.js +26 -0
- package/build/core/playwright/builtInFixtures/addTags.js +1 -1
- package/build/core/playwright/builtInFixtures/index.js +4 -3
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/index.js +6 -17
- package/build/core/playwright/readConfigFile.js +30 -30
- package/build/core/playwright/setup/config-creator.js +14 -13
- package/build/core/playwright/setup/config-utils.js +22 -32
- package/build/core/playwright/tag-processor.js +4 -2
- package/build/core/playwright/test-runner.js +42 -36
- package/build/decorators.d.ts +1 -1
- package/build/decorators.js +2 -16
- package/build/index.d.ts +60 -60
- package/build/index.js +12 -17
- package/build/parser/sample.feature +34 -34
- package/build/parser/sample.spec.js +18 -18
- package/build/setup-folder-structure/helper.js +0 -1
- package/build/setup-folder-structure/reportEnhancement/addonScript.html +24 -24
- package/build/setup-folder-structure/samples/auth-setup-sample.js +72 -72
- package/build/setup-folder-structure/samples/authUsers-sample.json +8 -8
- package/build/setup-folder-structure/samples/env-config-sample.json +20 -20
- package/build/setup-folder-structure/samples/git-ignore.sample.js +36 -36
- package/build/setup-folder-structure/samples/uat-config-sample.js +44 -44
- package/build/utils/cliArgsToObject.js +25 -25
- package/build/utils/fileUtils.js +19 -1
- package/build/utils/getFilePath.js +2 -1
- package/changelog.md +131 -137
- package/jest.config.js +63 -63
- package/npm-shrinkwrap.json +5980 -6469
- package/package.json +54 -55
- package/playwright.config.js +112 -112
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.parseFeature = parseFeature;
|
|
8
|
+
var _parserCucumber = _interopRequireDefault(require("./parserCucumber"));
|
|
9
|
+
function parseFeature(featureFileContent) {
|
|
10
|
+
var _gherkinDocument$feat;
|
|
11
|
+
var gherkinDocument = (0, _parserCucumber.default)(featureFileContent);
|
|
12
|
+
var currentFeature = {
|
|
13
|
+
feature: "",
|
|
14
|
+
featureTags: [],
|
|
15
|
+
scenarios: [],
|
|
16
|
+
featureBackGround: []
|
|
17
|
+
};
|
|
18
|
+
var isBackgroundExist;
|
|
19
|
+
currentFeature.feature = gherkinDocument.feature.name;
|
|
20
|
+
currentFeature.featureTags = (_gherkinDocument$feat = gherkinDocument.feature) === null || _gherkinDocument$feat === void 0 ? void 0 : _gherkinDocument$feat.tags.map(tag => tag.name);
|
|
21
|
+
gherkinDocument.feature.children.forEach($scenario => {
|
|
22
|
+
var _$scenario$scenario, _$scenario$scenario2, _$scenario$scenario3, _$scenario$scenario4;
|
|
23
|
+
var scenarioSteps = {
|
|
24
|
+
scenariodescription: "",
|
|
25
|
+
steps: [],
|
|
26
|
+
tablebody: false,
|
|
27
|
+
tableheader: false,
|
|
28
|
+
examples: [],
|
|
29
|
+
scenarioTags: [],
|
|
30
|
+
background: []
|
|
31
|
+
};
|
|
32
|
+
scenarioSteps.scenariodescription = (_$scenario$scenario = $scenario.scenario) === null || _$scenario$scenario === void 0 ? void 0 : _$scenario$scenario.name;
|
|
33
|
+
if ($scenario !== null && $scenario !== void 0 && $scenario.background) {
|
|
34
|
+
isBackgroundExist = $scenario.background.steps.map(element => {
|
|
35
|
+
return {
|
|
36
|
+
stepDescription: element.text,
|
|
37
|
+
keyword: element.keyword
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
(_$scenario$scenario2 = $scenario.scenario) === null || _$scenario$scenario2 === void 0 || _$scenario$scenario2.examples.map(example => {
|
|
43
|
+
var _example$tableHeader;
|
|
44
|
+
scenarioSteps.tablebody = example === null || example === void 0 ? void 0 : example.tableBody.map(cell => {
|
|
45
|
+
return cell === null || cell === void 0 ? void 0 : cell.cells.map(example => example.value);
|
|
46
|
+
});
|
|
47
|
+
scenarioSteps.tableheader = example === null || example === void 0 || (_example$tableHeader = example.tableHeader) === null || _example$tableHeader === void 0 ? void 0 : _example$tableHeader.cells.map(exampleHead => {
|
|
48
|
+
return exampleHead.value;
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
if (scenarioSteps.tablebody && scenarioSteps.tableheader) {
|
|
52
|
+
scenarioSteps.examples = testDataExtraction(scenarioSteps.tableheader, scenarioSteps.tablebody);
|
|
53
|
+
} else {
|
|
54
|
+
scenarioSteps.examples = false;
|
|
55
|
+
}
|
|
56
|
+
scenarioSteps.scenarioTags = (_$scenario$scenario3 = $scenario.scenario) === null || _$scenario$scenario3 === void 0 ? void 0 : _$scenario$scenario3.tags.map(tag => tag.name);
|
|
57
|
+
const _scenarioDescription = $scenario === null || $scenario === void 0 || (_$scenario$scenario4 = $scenario.scenario) === null || _$scenario$scenario4 === void 0 ? void 0 : _$scenario$scenario4.steps.map(step => {
|
|
58
|
+
return {
|
|
59
|
+
stepDescription: step.text,
|
|
60
|
+
keyword: step.keyword
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
scenarioSteps.steps = _scenarioDescription;
|
|
64
|
+
scenarioSteps.background = isBackgroundExist || [];
|
|
65
|
+
currentFeature.scenarios.push(scenarioSteps);
|
|
66
|
+
});
|
|
67
|
+
currentFeature.featureBackGround = currentFeature.scenarios[0].background;
|
|
68
|
+
return currentFeature;
|
|
69
|
+
}
|
|
70
|
+
function testDataExtraction(tableHeader, tableBody) {
|
|
71
|
+
const result = [];
|
|
72
|
+
if (tableBody && tableHeader) {
|
|
73
|
+
tableBody.forEach(array => {
|
|
74
|
+
const obj = {};
|
|
75
|
+
array.forEach((item, index) => {
|
|
76
|
+
obj[`<${tableHeader[index]}>`] = item;
|
|
77
|
+
});
|
|
78
|
+
result.push(obj);
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
@@ -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 _fileUtils = require("../../../utils/fileUtils");
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _pathConfig = require("../../config/pathConfig");
|
|
12
|
+
globalThis.inputsParamterMap = new Map();
|
|
13
|
+
async function readStepFile() {
|
|
14
|
+
const stepFilePath = (0, _pathConfig.getStepFilePath)();
|
|
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)(_path.default.resolve(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') || trimmedStep.startsWith('And') || trimmedStep.startsWith('Step')) {
|
|
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
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.generateSpecFiles = generateSpecFiles;
|
|
8
|
+
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _featureFileParer = require("../cucumber/featureFileParer");
|
|
11
|
+
var _testStructure = require("../testStructure");
|
|
12
|
+
var _fileUtils = require("../../../utils/fileUtils");
|
|
13
|
+
var _extractTestInputs = require("./extractTestInputs");
|
|
14
|
+
var _pathConfig = require("../../config/pathConfig");
|
|
15
|
+
function stepFileCreation(featureContent, stepFilename, featureFilePath) {
|
|
16
|
+
const stepsFilePath = _path.default.resolve(process.cwd(), 'uat', 'feature-gen', stepFilename);
|
|
17
|
+
const stepsSnippets = (0, _testStructure.testSnippet)(featureContent, featureFilePath);
|
|
18
|
+
(0, _fileUtils.writeFileContents)(stepsFilePath, stepsSnippets);
|
|
19
|
+
}
|
|
20
|
+
async function generateSpecFiles() {
|
|
21
|
+
const featureFilePattern = (0, _pathConfig.getFeatureFilePath)();
|
|
22
|
+
const generatedFolderPath = _path.default.resolve(process.cwd(), 'uat', 'feature-gen');
|
|
23
|
+
if (!(0, _fileUtils.checkIfFileExists)(generatedFolderPath)) {
|
|
24
|
+
(0, _fileUtils.createFolderSync)(generatedFolderPath, {
|
|
25
|
+
recursive: true
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
await (0, _extractTestInputs.readStepFile)();
|
|
29
|
+
_fastGlob.default.globSync(featureFilePattern, {
|
|
30
|
+
dot: true,
|
|
31
|
+
cwd: process.cwd()
|
|
32
|
+
}).forEach(filePath => {
|
|
33
|
+
const featurefilePath = _path.default.resolve(process.cwd(), filePath);
|
|
34
|
+
const featureContent = (0, _featureFileParer.parseFeature)((0, _fileUtils.readFileContents)(featurefilePath, 'utf-8'));
|
|
35
|
+
const fileName = _path.default.basename(filePath).replace('.feature', '.spec.js');
|
|
36
|
+
stepFileCreation(featureContent, fileName, filePath);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TESTING_LIBRARY = void 0;
|
|
7
|
+
exports.testBackGround = testBackGround;
|
|
8
|
+
exports.testCase = testCase;
|
|
9
|
+
exports.testFile = testFile;
|
|
10
|
+
exports.testStep = testStep;
|
|
11
|
+
exports.testSuite = testSuite;
|
|
12
|
+
const TESTING_LIBRARY = exports.TESTING_LIBRARY = '@zohodesk/testinglibrary';
|
|
13
|
+
function testStep(keyword, description, browserObject, testData, options) {
|
|
14
|
+
return `await $${keyword}('${description}')(${browserObject},${testData})\n`;
|
|
15
|
+
}
|
|
16
|
+
function testSuite(description, scenariotestBlock, tags, options = null) {
|
|
17
|
+
return `\ntest.describe('${description}${tags.join(" ")}', () => {
|
|
18
|
+
${scenariotestBlock}
|
|
19
|
+
})`;
|
|
20
|
+
}
|
|
21
|
+
function testCase(steps, examples, description, browserObjects, tags, option) {
|
|
22
|
+
if (examples.length >= 1) {
|
|
23
|
+
const exmapleScenario = examples.map(($ele, index) => {
|
|
24
|
+
var exampleDescription = Object.values($ele).map(val => {
|
|
25
|
+
return val.concat('-');
|
|
26
|
+
});
|
|
27
|
+
let avoidRepitationDescription = exampleDescription.join('').concat(`Example-${index + 1}`);
|
|
28
|
+
return testBlock(avoidRepitationDescription, steps, browserObjects);
|
|
29
|
+
});
|
|
30
|
+
return testSuite(description, exmapleScenario.join('\n'), tags);
|
|
31
|
+
}
|
|
32
|
+
return testSuite(`${description}-title`, testBlock(description, steps, browserObjects), tags);
|
|
33
|
+
}
|
|
34
|
+
function testBlock(description, steps, browserObjects) {
|
|
35
|
+
return `\ntest("${description}", async({${browserObjects.join(',')}}) => {
|
|
36
|
+
${steps.join(`\n\t`)}
|
|
37
|
+
})`;
|
|
38
|
+
}
|
|
39
|
+
function testFile(testCase, relativeFilePath, $tags, backgroundScenario = " ", options = null) {
|
|
40
|
+
return ` // ${relativeFilePath}
|
|
41
|
+
import { test, createNativeBDD } from "${TESTING_LIBRARY}";
|
|
42
|
+
const {$Given,$When,$Then,$And} = createNativeBDD()
|
|
43
|
+
\n
|
|
44
|
+
test.use({
|
|
45
|
+
$test: ({}, use) => use(test),
|
|
46
|
+
$tags: ({}, use, testInfo) => use(${JSON.stringify($tags)} \n [testInfo.titlePath.slice(2).join("|")] || [])
|
|
47
|
+
})
|
|
48
|
+
\n
|
|
49
|
+
${backgroundScenario}
|
|
50
|
+
\n
|
|
51
|
+
${testCase.join('')}
|
|
52
|
+
`;
|
|
53
|
+
}
|
|
54
|
+
function testBackGround(backgroundSteps, inputs) {
|
|
55
|
+
return ` test.beforeEach(async ({${inputs.join(',')}}) => { \n
|
|
56
|
+
${backgroundSteps.join(`\n`)}
|
|
57
|
+
});`;
|
|
58
|
+
}
|
|
@@ -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 === null || userArgs === void 0 ? void 0 : 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 === null || userArgs === void 0 ? void 0 : 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
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.testDataCreation = testDataCreation;
|
|
8
|
+
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
9
|
+
var _testStructure = require("./testStructure");
|
|
10
|
+
var _fileUtils = require("../../utils/fileUtils");
|
|
11
|
+
var _path = _interopRequireDefault(require("path"));
|
|
12
|
+
var _parserCucumber = _interopRequireDefault(require("./cucumber/parserCucumber"));
|
|
13
|
+
var _pathConfig = require("../config/pathConfig");
|
|
14
|
+
async function testDataCreation() {
|
|
15
|
+
var exampleSteps = [];
|
|
16
|
+
const globalTestdata = new Map();
|
|
17
|
+
const testDataFeatureFilePath = (0, _pathConfig.getFeatureFilePath)();
|
|
18
|
+
await _fastGlob.default.globSync(testDataFeatureFilePath, {
|
|
19
|
+
dot: true,
|
|
20
|
+
cwd: process.cwd()
|
|
21
|
+
}).forEach(filePath => {
|
|
22
|
+
var body, header;
|
|
23
|
+
var gherkinDocument = (0, _parserCucumber.default)((0, _fileUtils.readFileContents)(_path.default.resolve(process.cwd(), filePath), 'utf-8'));
|
|
24
|
+
gherkinDocument.feature.children.forEach($scenario => {
|
|
25
|
+
var _$scenario$scenario, _$scenario$scenario2;
|
|
26
|
+
const $currentScenario = {
|
|
27
|
+
currentArgument: '',
|
|
28
|
+
dataTableStep: '',
|
|
29
|
+
inputParameter: '',
|
|
30
|
+
input: false,
|
|
31
|
+
steptable: false,
|
|
32
|
+
scenarioTable: false
|
|
33
|
+
};
|
|
34
|
+
(_$scenario$scenario = $scenario.scenario) === null || _$scenario$scenario === void 0 || _$scenario$scenario.steps.forEach(step => {
|
|
35
|
+
var _step$dataTable;
|
|
36
|
+
const {
|
|
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, {});
|
|
45
|
+
}
|
|
46
|
+
const dataTableStep = [];
|
|
47
|
+
step === null || step === void 0 || (_step$dataTable = step.dataTable) === null || _step$dataTable === void 0 || _step$dataTable.rows.forEach(cell => {
|
|
48
|
+
const Table = cell.cells.map(element => element.value);
|
|
49
|
+
dataTableStep.push(Table);
|
|
50
|
+
});
|
|
51
|
+
if (step.dataTable) {
|
|
52
|
+
$currentScenario.dataTableStep = dataTableStep;
|
|
53
|
+
$currentScenario.steptable = true;
|
|
54
|
+
}
|
|
55
|
+
globalTestdata.set(refactoredStep, Object.assign({}, $currentScenario));
|
|
56
|
+
});
|
|
57
|
+
if (typeof $scenario.background === Object) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if ((_$scenario$scenario2 = $scenario.scenario) !== null && _$scenario$scenario2 !== void 0 && (_$scenario$scenario2 = _$scenario$scenario2.examples) !== null && _$scenario$scenario2 !== void 0 && _$scenario$scenario2.length) {
|
|
61
|
+
var _$scenario$scenario3;
|
|
62
|
+
exampleSteps = $scenario.scenario.steps.map(element => (0, _testStructure.extactStepArgs)(element.text).refactoredStep);
|
|
63
|
+
(_$scenario$scenario3 = $scenario.scenario) === null || _$scenario$scenario3 === void 0 || _$scenario$scenario3.examples.map(example => {
|
|
64
|
+
var _example$tableHeader;
|
|
65
|
+
body = example === null || example === void 0 ? void 0 : example.tableBody.map(cell => {
|
|
66
|
+
return cell === null || cell === void 0 ? void 0 : cell.cells.map(example => example.value);
|
|
67
|
+
});
|
|
68
|
+
header = example === null || example === void 0 || (_example$tableHeader = example.tableHeader) === null || _example$tableHeader === void 0 ? void 0 : _example$tableHeader.cells.map(exampleHead => {
|
|
69
|
+
return exampleHead.value;
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
const inputParameter = testDataExtraction(header, body);
|
|
73
|
+
exampleSteps.forEach(step => {
|
|
74
|
+
$currentScenario.inputParameter = Object.assign([], inputParameter);
|
|
75
|
+
$currentScenario.scenarioTable = true;
|
|
76
|
+
globalTestdata.set(step, Object.assign({}, $currentScenario));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
return globalTestdata;
|
|
82
|
+
}
|
|
83
|
+
function testDataExtraction(tableHeader, tableBody) {
|
|
84
|
+
const result = [];
|
|
85
|
+
if (tableBody && tableHeader) {
|
|
86
|
+
tableBody.forEach(array => {
|
|
87
|
+
const obj = {};
|
|
88
|
+
array.forEach((item, index) => {
|
|
89
|
+
obj[`${tableHeader[index].replace(/\s/g, '')}`] = item;
|
|
90
|
+
});
|
|
91
|
+
result.push(obj);
|
|
92
|
+
});
|
|
93
|
+
} else {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
return [...result];
|
|
97
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.extactStepArgs = extactStepArgs;
|
|
7
|
+
exports.testSnippet = testSnippet;
|
|
8
|
+
var _stringManipulation = require("../utils/stringManipulation");
|
|
9
|
+
var _stepsnippets = require("./stepGenerate/stepsnippets");
|
|
10
|
+
function testSnippet(featureContent, featureFilePath) {
|
|
11
|
+
var _featureContent$featu;
|
|
12
|
+
var currentScenarios = [];
|
|
13
|
+
var $tags = {};
|
|
14
|
+
featureContent.scenarios.forEach(scenario => {
|
|
15
|
+
scenario.scenarioTags = [...scenario.scenarioTags, ...featureContent.featureTags];
|
|
16
|
+
$tags = Object.assign($tags, handleInputTags(scenario));
|
|
17
|
+
const _constructStep = scenarioSnippet(scenario);
|
|
18
|
+
currentScenarios.push(_constructStep);
|
|
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
|
+
}
|
|
23
|
+
return (0, _stepsnippets.testFile)(currentScenarios, featureFilePath, $tags);
|
|
24
|
+
}
|
|
25
|
+
function extactStepArgs(step) {
|
|
26
|
+
var inputParam = [];
|
|
27
|
+
var currentArgument = {};
|
|
28
|
+
var refactoredStep = step.replace(/"([^"]+)"/g, (match, word) => {
|
|
29
|
+
if (!isNaN(Number(word))) {
|
|
30
|
+
inputParam.push(word.toString());
|
|
31
|
+
return '{int}';
|
|
32
|
+
} else {
|
|
33
|
+
inputParam.push(word.toString());
|
|
34
|
+
return '{string}';
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
currentArgument = inputParam.map(inputs => `"${(0, _stringManipulation.removeAll)(inputs, ['<', '>'], /\s/g)}"`);
|
|
38
|
+
return {
|
|
39
|
+
refactoredStep,
|
|
40
|
+
currentArgument
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function scenarioSnippet(scenario) {
|
|
44
|
+
var currentStep = [];
|
|
45
|
+
var currentInputs = [];
|
|
46
|
+
scenario.steps.forEach(step => {
|
|
47
|
+
var {
|
|
48
|
+
refactoredStep,
|
|
49
|
+
currentArgument
|
|
50
|
+
} = extactStepArgs(step.stepDescription);
|
|
51
|
+
var input = inputsParamterMap.get(`'${refactoredStep}'`);
|
|
52
|
+
currentInputs.push(input);
|
|
53
|
+
currentStep.push((0, _stepsnippets.testStep)(step.keyword, refactoredStep, input, currentArgument.join(',')));
|
|
54
|
+
return;
|
|
55
|
+
});
|
|
56
|
+
const pageObject = browserObjectHandle(currentInputs);
|
|
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);
|
|
58
|
+
}
|
|
59
|
+
function browserObjectHandle(arrayofBrowserObjects) {
|
|
60
|
+
var browserInputs = [];
|
|
61
|
+
arrayofBrowserObjects.forEach(pageObject => {
|
|
62
|
+
browserInputs = [...browserInputs, ...(0, _stringManipulation.removeAll)(pageObject, ['{', '}']).split(',')];
|
|
63
|
+
});
|
|
64
|
+
return (0, _stringManipulation.avoidDuplicate)(browserInputs);
|
|
65
|
+
}
|
|
66
|
+
function handleInputTags(scenario) {
|
|
67
|
+
var _scenario$examples;
|
|
68
|
+
if (((_scenario$examples = scenario.examples) === null || _scenario$examples === void 0 ? void 0 : _scenario$examples.length) >= 1) {
|
|
69
|
+
var _tagsObjects = {};
|
|
70
|
+
scenario.examples.forEach(($ele, index) => {
|
|
71
|
+
var exampleDescription = Object.values($ele).map(val => {
|
|
72
|
+
return val.concat('-');
|
|
73
|
+
});
|
|
74
|
+
Object.assign(_tagsObjects, {
|
|
75
|
+
[exampleDescription.join('').concat(`Example-${index + 1}`)]: scenario.scenarioTags
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
return _tagsObjects;
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
[scenario.scenariodescription]: scenario.scenarioTags
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function backgroundHandle(background) {
|
|
85
|
+
const currentBackground = [];
|
|
86
|
+
const backgroundInput = [];
|
|
87
|
+
background.forEach(b_scenario => {
|
|
88
|
+
var {
|
|
89
|
+
refactoredStep,
|
|
90
|
+
currentArgument
|
|
91
|
+
} = extactStepArgs(b_scenario.stepDescription);
|
|
92
|
+
var input = inputsParamterMap.get(`'${refactoredStep}'`);
|
|
93
|
+
backgroundInput.push(input);
|
|
94
|
+
currentBackground.push((0, _stepsnippets.testStep)(b_scenario.keyword, refactoredStep, input, currentArgument.join(',')));
|
|
95
|
+
return;
|
|
96
|
+
});
|
|
97
|
+
return (0, _stepsnippets.testBackGround)(currentBackground, browserObjectHandle(backgroundInput));
|
|
98
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.avoidDuplicate = avoidDuplicate;
|
|
7
|
+
exports.filePathPattern = filePathPattern;
|
|
8
|
+
exports.removeAll = removeAll;
|
|
9
|
+
function removeAll(InputString, toRemove, regex = undefined, options = null) {
|
|
10
|
+
if (regex) {
|
|
11
|
+
InputString = InputString.replace(regex, '').trim();
|
|
12
|
+
}
|
|
13
|
+
toRemove.forEach(ele => {
|
|
14
|
+
InputString = InputString.replace(ele, '').trim();
|
|
15
|
+
});
|
|
16
|
+
return InputString;
|
|
17
|
+
}
|
|
18
|
+
function avoidDuplicate(arrayOfInputs) {
|
|
19
|
+
return [...new Set(arrayOfInputs)];
|
|
20
|
+
}
|
|
21
|
+
function filePathPattern(filePath, isWindows = true) {
|
|
22
|
+
if (isWindows) {
|
|
23
|
+
return filePath.split('\\').join('/');
|
|
24
|
+
}
|
|
25
|
+
return filePath;
|
|
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;
|
|
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CUSTOM_COMMANDS = void 0;
|
|
7
|
-
const CUSTOM_COMMANDS = exports.CUSTOM_COMMANDS = ['mode', 'tags', 'edition'
|
|
7
|
+
const CUSTOM_COMMANDS = exports.CUSTOM_COMMANDS = ['mode', 'tags', 'edition'];
|
|
@@ -4,13 +4,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.When = exports.Then = exports.Given = void 0;
|
|
8
|
-
Object.defineProperty(exports, "createBdd", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function () {
|
|
11
|
-
return _bddFramework.createBdd;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
7
|
Object.defineProperty(exports, "expect", {
|
|
15
8
|
enumerable: true,
|
|
16
9
|
get: function () {
|
|
@@ -18,25 +11,21 @@ Object.defineProperty(exports, "expect", {
|
|
|
18
11
|
}
|
|
19
12
|
});
|
|
20
13
|
exports.test = void 0;
|
|
21
|
-
var _bddFramework = require("../../bdd-framework");
|
|
22
14
|
var _test = require("@playwright/test");
|
|
23
15
|
var _readConfigFile = require("./readConfigFile");
|
|
24
16
|
var _builtInFixtures = _interopRequireDefault(require("./builtInFixtures"));
|
|
17
|
+
// import { createBdd, test as bddBase } from '../../bdd-framework';
|
|
18
|
+
|
|
25
19
|
const {
|
|
26
20
|
additionalPages: userFixtures,
|
|
27
21
|
bddMode
|
|
28
22
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
29
|
-
|
|
23
|
+
// In house BDD testing. so, use playwright test
|
|
24
|
+
let base = _test.test;
|
|
30
25
|
const buildInFixtures = (0, _builtInFixtures.default)(bddMode);
|
|
31
26
|
const test = exports.test = base.extend({
|
|
32
27
|
...buildInFixtures,
|
|
33
28
|
...userFixtures
|
|
34
29
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
When,
|
|
38
|
-
Then
|
|
39
|
-
} = (0, _bddFramework.createBdd)();
|
|
40
|
-
exports.Then = Then;
|
|
41
|
-
exports.When = When;
|
|
42
|
-
exports.Given = Given;
|
|
30
|
+
|
|
31
|
+
// const { Given, When, Then } = createBdd();
|